diff options
Diffstat (limited to '3808/CH7/EX7.8/Ex7_8.sce')
-rw-r--r-- | 3808/CH7/EX7.8/Ex7_8.sce | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/3808/CH7/EX7.8/Ex7_8.sce b/3808/CH7/EX7.8/Ex7_8.sce new file mode 100644 index 000000000..583f32afd --- /dev/null +++ b/3808/CH7/EX7.8/Ex7_8.sce @@ -0,0 +1,34 @@ +//Chapter 07: Discrete Probability + +clc; +clear; + +times=7 //no of times flipped +total_outcomes=2**times //outcomes power times flipped + +function result=combination(n,r) //function definition +i=n +num=1 +denominator=1 +l=(n-r)+1 +u=n +for i=l:u //to compute the value of the numerator +num=num*i +end +for j=1:r //to compute the value of the denominator +denominator=denominator*j +end +result=num/denominator +return result +endfunction + +reqd_heads=4 //no of heads coming up +ways_heads=combination(times,reqd_heads) +pH=2/3 //biased coin with probability of heads for 1 head +pT=1-pH //probability of tails is total probability-heads probability +rpH=pH**reqd_heads //probability of 4 heads outcome +rpT=pT**(times-reqd_heads) //probability of tails outcome + +prob_four_heads=ways_heads*rpH*rpT //probability of exactly four heads appearing + +disp(prob_four_heads,'The probability of exactly four heads appearing is') |