1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
|
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Chapter 7: Probability Theory"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example 7.10: Repeated_trials_with_two_outcomes.sci"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"n=6; //number of times a fair coin is tossed and getting a heads is a success\n",
"p=1/2; //probability of getting a heads\n",
"q=1/2 ; //probability of not getting a heads\n",
"P2=(factorial(6)/(factorial(6-2)*factorial(2)))*p^2*q^(6-2); \n",
"disp(P2,'probability of getting exactly two heads (i.e k=2)')\n",
"\n",
"P4=(factorial(6)/(factorial(6-4)*factorial(4)))*p^4*q^(6-4); //probabilty of getting four heads\n",
"P5=(factorial(6)/(factorial(6-5)*factorial(5)))*p^5*q^(6-5); //probabilty of getting five heads\n",
"P6=(factorial(6)/(factorial(6-6)*factorial(6)))*p^6*q^(6-6); //probabilty of getting five heads\n",
"PA=P4+P5+P6 ; \n",
"disp(PA,'probability of getting atleast four heads(i.e k=4,5 or 6)')\n",
" \n",
"Pn=q^6 //probability of getting no heads\n",
"Pm=1-Pn;\n",
"disp(Pm,'probability of getting one or more heads')"
]
}
,
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example 7.12: Random_variables.sci"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"disp('A box contains 12 items of which three are defective')\n",
"disp('A sample of three items is selected from the box')\n",
"s=factorial(12)/(factorial(12-3)*factorial(3)); \n",
"disp(s,'number of elements in the sample space where samples are of size 3')\n",
"//X denotes the number of defective items in the sample\n",
"x=[0,1,2,3]; //range space of the random variable X"
]
}
,
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example 7.13: Probability_distribution_of_a_random_variable.sci"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"r=[1,2,3,4,5,6,5,4,3,2,1]; \n",
"//number of outcomes whose sum is 2,3,4,5,6,7,8,9,10,11,12 respectively such that there is only 1 outcome i.e (1,1) whose sum is 2,two outcomes (1,2) and (2,1) whose sum is 3 and so on\n",
"t=36; //total number of elements in the sample space of the experiment of tossing a pair of dice\n",
"for i=1:11;\n",
"p=r(i)/t;\n",
"disp(p)\n",
"end\n",
"0.0277778 //probability of getting a sum of 2\n",
"0.0555556 //probability of getting a sum of 3\n",
"0.0833333 //probability of getting a sum of 4\n",
"0.1111111 //probability of getting a sum of 5 \n",
"0.1388889 //probability of getting a sum of 6\n",
"0.1666667 //probability of getting a sum of 7\n",
"0.1388889 //probability of getting a sum of 8\n",
"0.1111111 //probability of getting a sum of 9\n",
"0.0833333 //probability of getting a sum of 10\n",
"0.0555556 //probability of getting a sum of 11\n",
"0.0277778 //probability of getting a sum of 12\n",
"x=[2,3,4,5,6,7,8,9,10,11,12]; //range space of random variable X which assigns to each point in sample space the sum of the numbers \n",
"D=[ 2,3,4,5,6,7,8,9,10,11,12; 0.0277778, 0.0555556 , 0.0833333, 0.1111111, 0.1388889 ,0.1666667, 0.1388889 ,0.1111111, 0.0833333, 0.0555556, 0.0277778];\n",
"disp(D,'distribution table of X where first row gives the range space and second row gives the respective probabilities is as follows')"
]
}
,
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example 7.14: Probability_distribution_of_a_random_variable.sci"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"disp('a box contains 12 items of which three are defective')\n",
"disp('A sample of three items is selected from the box')\n",
"r=factorial(9)/(factorial(9-3)*factorial(3)) //number of samples of size 3 with no defective items\n",
"t=220; //number of different samples of size 3 i.e the number of elements in the sample space\n",
"P0=r/t //probability of getting no defective item\n",
"r1=3*(factorial(9)/(factorial(9-2)*factorial(2))) //number of samples of size 3 getting 1 defective item\n",
"P1=r1/t //probability of getting 1 defective item\n",
"r2=9*(factorial(3)/(factorial(3-2)*factorial(2))) //number of samples of size 3 getting 2 defective item\n",
"P2=r2/t //probability of getting 2 defective item\n",
"r3=1; //number of samples of size 3 getting 3 defective item\n",
"P3=r3/t //probability of getting 3 defective item\n",
"x=[0,1,2,3];\n",
"p=[P0,P1,P2,P3];\n",
"D=[0,1,2,3;P0,P1,P2,P3]; \n",
"disp(D,'distribution table for random variable X the upper row being values of X')"
]
}
,
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example 7.15: Expectation_of_a_random_variable.sci"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"disp('A fair coin is tossed six times');\n",
"x=[0,1,2,3,4,5,6]; //number of heads which can occur\n",
"p=[1/64,6/64,15/64,20/64,15/64,6/64,1/64]; //probability of occurring of heads where 1/64 is probability for occurrence of a single head,6/64 that of occurrence of two heads and so on.\n",
"r=0;\n",
"for i=1:7;\n",
"r = r + (x(i)*p(i));\n",
"end\n",
"disp(r,'mean or expected number of heads are')\n",
" \n",
"disp('X is a random variable which gives possible number of defective items in a sample of size 3');\n",
"//Box contains 12 items of which three are defective\n",
"x=[0,1,2,3]; //possible number of defective items in a smaple of size 3\n",
"p=[84/220,108/220,27/220,1/220]; //probability of occurrence of each number in x respectively where 84/220 is the probability for getting no defective item,108/220 is that of getting 1 defective item and so on.\n",
" r=0;\n",
"for i=1:4;\n",
"r = r + (x(i)*p(i));\n",
"end\n",
"disp(r,'expected number of defective items in a sample of size 3 are')\n",
" \n",
"Ph1=1/2; //probability of winning the race by first horse\n",
"Ph2=1/3; //probability of winning the race by second horse\n",
"Ph3=1/6; //probability of winning the race by third horse\n",
"//X is the payoff function for the winning horse\n",
"X1=2; //X pays $2 as first horse wins the rac\n",
"X2=6; //X pays $6 as second horse wins the race\n",
"X3=9; //X pays $9 as third horse wins the race\n",
"E=X1*Ph1+X2*Ph2+X3*Ph3; \n",
"disp(E,'expected pay off for the race is')"
]
}
,
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example 7.16: Variance_and_standard_deviation_of_a_random_variable.sci"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"u=3; //mean of distribution of random variable X\n",
"x=[0,1,2,3,4,5,6]; //values of X in the distribution as x where it is the number of times heads occurs when a coin is tossed six times\n",
"p=[1/64,6/64,15/64,20/64,15/64,6/64,1/64]; //probabilities of occurrence of each value of X (x) in the distribution such that 1/64 gives the probability of occurrence of no heads at all,6/64 gives that of occurrence of heads for only one time and so on\n",
"k=0;\n",
"for i=1:7;\n",
"k=k+((x(i)-u)^2)*p(i);\n",
"end\n",
"disp(k,'Variance of X is')\n",
"s=sqrt(k);\n",
"disp(s,'Standard deviation of X is')\n",
"\n",
"u=0.75; //mean \n",
"x=[0,1,2,3]; //values of random variable X as x in the probability distribution of X\n",
"p=[84/220,108/220,27/220,1/220]; //probability of values in x which appear in distribution table of X\n",
"g=0;\n",
"for i=1:4;\n",
"g=g+((x(i))^2)*p(i);\n",
"end\n",
"h=g-(u*u); \n",
"disp(h,'variance of X is')\n",
"sd=sqrt(h);\n",
"disp(sd,'Standard deviation for X')"
]
}
,
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example 7.17: Binomial_diatribution.sci"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"p=1/5; //probability of the man hitting a target\n",
"q=1-1/5; //probability of the man not hitting the target\n",
"n=100; //number of times the man fires\n",
"e=n*p; \n",
"disp(e,'expected number of times the man will hit the target')\n",
"r=sqrt(n*p*q); \n",
"disp(r,'Standard deviation')\n",
"\n",
"p=1/2; //probability of guessing the correct answer in a five question true-false exam\n",
"n=5; //number of questions in the exam\n",
"g=n*p;\n",
"disp(g,'expected number of correct answers in the exam')"
]
}
,
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example 7.18: Chebyshev_inequality.sci"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"u=75; //mean of a random variable X\n",
"n=5; //standard deviation of X\n",
"k=2; //for k=2\n",
"l1=u-k*n\n",
"l2=u+k*n\n",
"P1=1-(1/k)^2\n",
"disp('thus the probability that a value of X lies between 65 and 85 is atleast 0.75 according to Chebyshev inequality')\n",
"k=3; //for k=3\n",
"l1=u-k*n\n",
"l2=u+k*n\n",
"P2=1-(1/k)^2\n",
"disp('thus the probability that a value of X lies between 60 and 90 is atleast 0.8888889 according to Chebyshev Inequality')"
]
}
,
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example 7.19: Sample_mean_and_Law_of_large_numbers.sci"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"disp(' a die is tossed 5 times with the following outcomes')\n",
"x1=3;\n",
"x2=4;\n",
"x3=6;\n",
"x4=1;\n",
"x5=4;\n",
"xmean=(x1+x2+x3+x4+x5)/5 //mean of the outcomes\n",
"disp('for a fair die the mean is 3.5.So law of large numbers tells us that as number of outcomes increase for this experiment,there is a greater likelihood that themean will get closer to 3.5')"
]
}
,
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example 7.1: Sample_space_and_events.sci"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"S=[1,2,3,4,5,6]; //sample space for the rolling of a die\n",
"A=[2,4,6]; //event that an even number occurs\n",
"B=[1,3,5]; //event that an odd number occurs\n",
"C=[2,3,5]; //event that a prime number occurs\n",
"disp(union(A,C),'sample space for the event that an even or a prime number occurs')\n",
"disp(intersect(B,C),'sample space for the event that an odd prime number occurs')\n",
"disp(setdiff(S,C),'sample space for the event that a prime number does not occur') //It is the complement of the set C.\n",
"intersect(A,B) //It is a null set or null vector since there can't occur an even and an odd number simultaneously\n",
" \n",
"H=0; //'head' face of a coin\n",
"T=1; //'tail' face of a coin\n",
"S=['000','001','010','011','100','101','110','111'] ; //sample space for the toss of a coin three times\n",
"A=['000','001','100']; //event that two more or more heads appear consecutively\n",
"B=['000','111']; //event that all tosses are the same\n",
"disp(intersect(A,B),'sample space for the event in which only heads appear')\n",
" \n",
"disp('Experiment:tossing a coin until a head appears and then counting the number of times the coin is tossed')\n",
"S=[1,2,3,4,5,%inf] //The sample space has infinite elements in it\n",
"disp('Since every positive integer is an element of S,the sample space is infinite')"
]
}
,
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example 7.2: Finite_probability_spaces.sci"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"disp('Experiment:three coins are tossed and the number of heads are observed')\n",
"S=[0,1,2,3]; //the sample space for the experiment where 0 implies no heads,1 implies only one head out of the three coins and so on\n",
"disp('the probability space is as follows ') \n",
"P0=1/8; //probability of getting no head on any of the coins i.e TTT\n",
"P1=3/8; //probability of getting only one head on any of the coins, out of the three coins i.e HTT,THT,TTH\n",
"P2=3/8; //probability of getting two heads, out of the three coins i.e THH,HTH,HHT\n",
"P3=1/8; //probability of getting all the three heads i.e HHH\n",
"disp('A is the event that atleast one head appears and B is the event that all heads or all tails appear ')\n",
"A=[1,2,3]; // HHH,HHT,HTH,HTT,THH,THT,TTH\n",
"B=[0,3]; //HHH,TTT\n",
"PA=P1+P2+P3; \n",
"disp(PA,'probability of occurrence of event A')\n",
"PB=P0+P3; \n",
"disp(PB,'probability of occurrence of event B') "
]
}
,
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example 7.3: Equiprobable_spaces.sci"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"disp('Experiment: a card is selected from a deck of 52 cards ') \n",
"disp('A is the event of the selected card being a spade ') \n",
"disp('B is the event of the selected card being a face card ') \n",
"t=52 ; //the total number of cards\n",
"s=13; //number of spades\n",
"PA= s/t; \n",
"disp(PA,'probability of selecting a spade')\n",
"f=12; //number of face cards(jack,queen,king)\n",
"PB=f/t;\n",
"disp(PB,'probability of selecting a face card')\n",
"sf=3; //number of spade face cards\n",
"Psf=sf/t;\n",
"disp(Psf,'probability of selecting a spade face card is:')"
]
}
,
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example 7.4: Addition_principle.sci"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"disp('Experiment: selection of a student out of 100 students ') \n",
"M=30; //no of students taking mathematics\n",
"C=20; //no of students taking chemistry\n",
"T=100; //total no. of students\n",
"PM = M/T //probability of the selected student taking mathematics\n",
"PC = C/T //probability of the selected student taking chemistry\n",
"MnC=10; //no of students taking mathematics and chemistry\n",
"PMnC = MnC/T //probability of the selected student taking mathematics and chemistry both\n",
"PMorC = PM+PC-PMnC; \n",
"disp(PMorC,'probability of the selected student taking mathematics or chemistry')"
]
}
,
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example 7.5: Conditional_probability.sci"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"\n",
" \n",
"//EXAMPLE 7.5 (a)\n",
" \n",
" \n",
" disp(' Experiment: A die is tossed and the outcomes are observed');\n",
" \n",
"\n",
" disp('To find: probability (PM) of an event that one of the dice is 2 if the sum is 6'); \n",
" \n",
" \n",
"E=['(1,5)','(2,4)','(3,3)','(4,2)','(5,1)'] //event that the sum of the two numbers on the two dice is 6\n",
" \n",
" \n",
"A=['(2,1)','(2,2)','(2,3)','(2,4)','(2,5)','(2,6)','(1,2)','(3,2)','(4,2)','(5,2)','(6,2)'] //event that 2 appears on atleast one die\n",
" \n",
"\n",
"B= intersect(A,E) //possible combination of numbers on two die such that their sum is 6 and 2 appears atleast on one die\n",
" \n",
" \n",
"PM=2/5 //since E has 5 elements and B has 2 elements\n",
" \n",
" \n",
"\n",
"\n",
"\n",
"//EXAMPLE 7.5(b)\n",
" \n",
"disp('A couple has two children');\n",
"\n",
" \n",
"b=1; //boy child\n",
" \n",
"g=2; //girl child\n",
"\n",
"S=[11,12,21,22] ; //sample space where 11 implies both children being boys,12 implies first child being a boy and the second child being a girl and so on\n",
" \n",
"disp('To find: probability(PM) that both children are boys ');\n",
" \n",
" \n",
"\n",
"//7.5(b).i\n",
" \n",
"L=S(:,1:3) //reduced sample space if it is known that one of the children is a boy\n",
" \n",
" \n",
"PM=1/length(L)\n",
" \n",
" \n",
"//7.5(b).ii\n",
" \n",
"R=S(:,1:2) //reduced sample space if it is known that the older child is a boy\n",
" \n",
" \n",
"PM=1/length(R)\n",
" \n",
" \n",
"\n",
""
]
}
,
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example 7.6: Multiplication_theorem_for_conditional_probability.sci"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"disp('A bag contains 12 items of which four are defective.Three items are drawn at random,one after the other');\n",
"s=12; //total itmes in the bag\n",
"d=4; //defective items in the bag\n",
"Pf=(s-d)/s ; //probability that the first item drawn is non defective\n",
"Pe=Pf*[(s-d-1)/(s-1)]*[(s-d-2)/(s-2)];\n",
"disp(Pe,'probability that all three items are non defective')\n",
"//after the first item is chosen,the second item is to be chosen from 1 less than the original number of items in the box and similarly the number of non defective items gets decreased by 1.Similarly ,for the third draw of item from the box"
]
}
,
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example 7.7: Independent_events.sci"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"H=1; //heads of a coin\n",
"T=2; //tails of the coin\n",
"S=[111,112,121,122,211,212,221,222] //sample space for the toss of a coin three times. 111 implies heads all three times,112 implies heads on first two tosses and tails on the third toss\n",
"A=[111,112,121,122]; //event that first toss is heads\n",
"B=[111,112,211,212]; //event that second toss is heads\n",
"C=[112,211]; //event that exactly two heads appear in a row\n",
"PA=length(A)/length(S);\n",
"disp(PA,'probability of A is')\n",
"PB=length(B)/length(S);\n",
"disp(PB,'probability of B is')\n",
"PC=length(C)/length(S);\n",
"disp(PC,'probability of C is')\n",
"AnB=intersect(A,B)\n",
"AnC=intersect(A,C)\n",
"BnC=intersect(B,C)\n",
"PAnB= length(AnB)/length(S);\n",
"disp(PAnB,'probability of the event AnB')\n",
"PAnC= length(AnC)/length(S);\n",
"disp(PAnC,'probability of the event AnC') \n",
"PBnC= length(BnC)/length(S);\n",
"disp(PBnC,'probability of the event BnC') \n",
"if((PA*PB)==PAnB),\n",
" disp('A and B are independent')\n",
"else\n",
" disp('A and B are dependent')\n",
"end\n",
"if((PA*PC)==PAnC),\n",
" disp('A and C are independent')\n",
"else\n",
" disp('A and C are dependent')\n",
"end\n",
"if((PB*PC)==PBnC),\n",
" disp('B and C are independent')\n",
"else\n",
" disp('B and C are dependent')\n",
"end"
]
}
,
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example 7.8: Independent_events.sci"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"disp('Experiment: A and B both shoot at a target') \n",
"PA=1/4; //given probability of A hitting the target\n",
"PB=2/5; //given probability of B hitting the target\n",
"disp('A and B are independent events so PA*PB will be equal to probability of the event of A and B both hitting the target i.e PAnB')\n",
"PAnB=PA*PB;\n",
"PAorB=PA+PB-PAnB;\n",
"disp(PAorB,'probability of atleast one of them hitting the target')"
]
}
,
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example 7.9: Independent_repeated_trials.sci"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"disp('Experiment: Three horses race together twice') \n",
"Ph1=1/2; //probability of first horse winning the race\n",
"Ph2=1/3; //probability of second horse winning the race\n",
"Ph3=1/6; //probability of third horse winning the race\n",
"S=[11,12,13,21,22,23,31,32,33] //sample space where 11 implies first horse winning the first and second race both,12 implies first horse winning the first race and second horse winning the second race and so on\n",
"P11=Ph1*Ph1 //probability of first horse winning both races\n",
"P12=Ph1*Ph2 //probability of first horse winning the first race and second horse winning the second race\n",
"P13=Ph1*Ph3 //probability of first horse winning the first race and third horse winning the second race\n",
"P21=Ph2*Ph1 //probability of second horse winning the first race and first horse winning the second race\n",
"P22=Ph2*Ph2 //probability of second horse winning both the races\n",
"P23=Ph2*Ph3 //probability of second horse winning the first race and third horse winning the second race\n",
"P31=Ph3*Ph1 //probability of third horse winning the first race and first horse winning the second race\n",
"P32=Ph3*Ph2 //probability of third horse winning the first race and second horse winning the second race\n",
"P33=Ph3*Ph3 //probability of third horse winning both the races \n",
"disp(P31,'probability of third horse winning the first race and first horse winning the second race is')"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Scilab",
"language": "scilab",
"name": "scilab"
},
"language_info": {
"file_extension": ".sce",
"help_links": [
{
"text": "MetaKernel Magics",
"url": "https://github.com/calysto/metakernel/blob/master/metakernel/magics/README.md"
}
],
"mimetype": "text/x-octave",
"name": "scilab",
"version": "0.7.1"
}
},
"nbformat": 4,
"nbformat_minor": 0
}
|