%
clear all
close all

  disp('Left-handed Families')
  lw = 2; 
  set(0, 'DefaultAxesFontSize', 14);
  fs = 14;
  msize = 10;  
% About 10% of the world's population is left-handed. 
% Left handedness is more prevalent in men (1/9) than in the women (1/13).
% Studies have shown that left-handedness is linked to the gene LRRTM1, 
% which affects the symmetry of the brain, but in addition to its 
% genetic origins, left-handedness also has developmental origins.
% When both parents are left-handed, a child is left-handed with 
% the probability of 0.26.
% 
% Ten families in which both parents are left-handed and have a single  
% child are selected and the ten children are inspected for left-handedness. 
% Let X  be the number of left-handed among the inspected.
% What is the probability that X 
% 
% (a) is equal to 3;
% (b) falls anywhere between 3 and 6, inclusive;
% (c) is at most 4;
% (d) not less than 4.
% (e) Would you be surprised if the number of left-handed 
%       children among the 10 inspected was 8? Why or why not?

%Solution 
disp('(a) Bin(10, 0.26): P(X = 3)');
binopdf(3, 10, 0.26)
%ans = 0.2563 
disp('(b) Bin(10, 0.26): P(3 <= X <= 6)');
%using binopdf(x, n, p) 
disp('(b)-using pdf');   binopdf(3, 10, 0.26) + ...
binopdf(4, 10, 0.26) + binopdf(5, 10, 0.26) + binopdf(6, 10, 0.26)
%using binocdf(x, n, p) 
disp('(b)-using cdf'); binocdf(6, 10, 0.26) - binocdf(2, 10, 0.26)
%ans = 0.4998 
%(c) at most four i.e., X <= 4 
disp('(c) Bin(10, 0.26): P(X <= 4)'); binocdf(4, 10, 0.26)
%ans = 0.9096 
%(d) not less than 4 is 4,5,...,10, or complement of <=3 
disp('(d)  Bin(12, 0.7): P(X >= 4)'); 1-binocdf(3, 10, 0.26)
%ans = 0.2479 
disp('(e) Bin(10, 0.26): P(X = 8)');
binopdf(8, 10, 0.26)
%ans = 5.1459e-004 
%Yes, this is a surprizing outcome since the probability 
%of this event is rather small, 0.0005. 

