React Native Developer

Saturday, March 23, 2019

Statistical Methods (SM)




Bhagwan Mahavir College of Management
BMEF Campus, VIP Road, Bharthana Vesu, Surat.

Lab Manual
On
4649303Statistical Methods (SM)  
      
  Subject Code: 4649302

M.C.A. – 4th Semester    





Submitted By :                                                                                 Submitted To :     58 – Paresh Chavda                                                                                                  Prof. Harshad Patel





Relative frequency:
Q.1

data=c("android","java","sm","jwt","python","c","c++","php","Core java")
> data
[1] "android"   "java"      "sm"        "jwt"       "python"    "c"         "c++"     
[8] "php"       "Core java"

data.freq=table(data)
> data.freq
data
  android         c       c++ Core java      java       jwt       php    python        sm
        1         1         1         1         1         1         1         1         1
> data.rel=data.freq/nrow(data.freq)
> data.rel
data
  android         c       c++ Core java      java       jwt       php    python        sm
0.1111111 0.1111111 0.1111111 0.1111111 0.1111111 0.1111111 0.1111111 0.1111111 0.1111111
> data.per=data.rel*100
> data.per
data
  android         c       c++ Core java      java       jwt       php    python        sm
 11.11111  11.11111  11.11111  11.11111  11.11111  11.11111  11.11111  11.11111  11.11111
> barplot(data.freq)
> pie(data.freq)
> cbind(data.freq,data.rel,data.per)
          data.freq  data.rel data.per
android           1 0.1111111 11.11111
c                 1 0.1111111 11.11111
c++               1 0.1111111 11.11111
Core java         1 0.1111111 11.11111
java              1 0.1111111 11.11111
jwt               1 0.1111111 11.11111
php               1 0.1111111 11.11111
python            1 0.1111111 11.11111
sm                1 0.1111111 11.11111
                                                                                          Q.2
library(MASS)
> data()
> phones
$year
 [1] 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73

$calls
 [1]   4.4   4.7   4.7   5.9   6.6   7.3   8.1   8.8  10.6  12.0  13.5  14.9
[13]  16.1  21.2 119.0 124.0 142.0 159.0 182.0 212.0  43.0  24.0  27.0  29.0

duration=phones$calls
> duration
 [1]   4.4   4.7   4.7   5.9   6.6   7.3   8.1   8.8  10.6  12.0  13.5  14.9
[13]  16.1  21.2 119.0 124.0 142.0 159.0 182.0 212.0  43.0  24.0  27.0  29.0
> 
duration.freq=table(duration)
> cbind(duration.freq)
     duration.freq
4.4              1
4.7              2
5.9              1
6.6              1
7.3              1
8.1              1
8.8              1
10.6             1
12               1
13.5             1
14.9             1
16.1             1
21.2             1
24               1
27               1
29               1
43               1
119              1
124              1
142              1
159              1
182              1
212              1
> duration.rel=duration.freq/nrow(duration.freq)
> duration.rel
duration
       4.4        4.7        5.9        6.6        7.3        8.1        8.8
0.04347826 0.08695652 0.04347826 0.04347826 0.04347826 0.04347826 0.04347826
      10.6         12       13.5       14.9       16.1       21.2         24
0.04347826 0.04347826 0.04347826 0.04347826 0.04347826 0.04347826 0.04347826
        27         29         43        119        124        142        159
0.04347826 0.04347826 0.04347826 0.04347826 0.04347826 0.04347826 0.04347826
       182        212
0.04347826 0.04347826
> barplot(duration.freq)
> pie(duration.freq)
> cbind(duration.freq,duration.rel,duration.per)
     duration.freq duration.rel duration.per
4.4              1   0.04347826     4.347826
4.7              2   0.08695652     8.695652
5.9              1   0.04347826     4.347826
6.6              1   0.04347826     4.347826
7.3              1   0.04347826     4.347826
8.1              1   0.04347826     4.347826
8.8              1   0.04347826     4.347826
10.6             1   0.04347826     4.347826
12               1   0.04347826     4.347826
13.5             1   0.04347826     4.347826
14.9             1   0.04347826     4.347826
16.1             1   0.04347826     4.347826
21.2             1   0.04347826     4.347826
24               1   0.04347826     4.347826
27               1   0.04347826     4.347826
29               1   0.04347826     4.347826
43               1   0.04347826     4.347826
119              1   0.04347826     4.347826
124              1   0.04347826     4.347826
142              1   0.04347826     4.347826
159              1   0.04347826     4.347826
182              1   0.04347826     4.347826
212              1   0.04347826     4.347826
                                                                       
                                                                        Q-3
> library(MASS)
> data()

> shoes
$A
 [1] 13.2  8.2 10.9 14.3 10.7  6.6  9.5 10.8  8.8 13.3

$B
 [1] 14.0  8.8 11.2 14.2 11.8  6.4  9.8 11.3  9.3 13.6

> price=shoes$A
> price
 [1] 13.2  8.2 10.9 14.3 10.7  6.6  9.5 10.8  8.8 13.3
> price.freq=table(price)
> price
 [1] 13.2  8.2 10.9 14.3 10.7  6.6  9.5 10.8  8.8 13.3
> cbind(price.freq)
     price.freq
6.6           1
8.2           1
8.8           1
9.5           1
10.7          1
10.8          1
10.9          1
13.2          1
13.3          1
14.3          1
> price.rel=price.freq/nrow(price.freq)
> price.rel
price
 6.6  8.2  8.8  9.5 10.7 10.8 10.9 13.2 13.3 14.3
 0.1  0.1  0.1  0.1  0.1  0.1  0.1  0.1  0.1  0.1
> barplot(price.freq)
> pie(price.freq)
> cbind(price.freq,price.rel,price.per)
> 

* Cumulative frequency

Q.1

> duration = painters$Drawing
> duration
 [1]  8 16 13 16 15 16 17 16 12 18 13 15 15 14 14 15 15 14 10 12 15 15  8  6  9
[26]  8  9  6 14 14 15 10 14  6 13 17 10 13 17 10 10 15  6 10  8 14  6 13 12 10
[51]  8 16 15 17

> range(duration)
[1]  6 18

> breaks = seq(5,20,by=5)
> breaks
[1]  5 10 15 20

> duration.cut = cut(duration,breaks)
> duration.cut
 [1] (5,10]  (15,20] (10,15] (15,20] (10,15] (15,20] (15,20] (15,20] (10,15]
[10] (15,20] (10,15] (10,15] (10,15] (10,15] (10,15] (10,15] (10,15] (10,15]
[19] (5,10]  (10,15] (10,15] (10,15] (5,10]  (5,10]  (5,10]  (5,10]  (5,10]
[28] (5,10]  (10,15] (10,15] (10,15] (5,10]  (10,15] (5,10]  (10,15] (15,20]
[37] (5,10]  (10,15] (15,20] (5,10]  (5,10]  (10,15] (5,10]  (5,10]  (5,10]
[46] (10,15] (5,10]  (10,15] (10,15] (5,10]  (5,10]  (15,20] (10,15] (15,20]
Levels: (5,10] (10,15] (15,20]

> duration.freq=table(duration.cut)
> duration.freq
duration.cut
 (5,10] (10,15] (15,20]
     19      25      10

> duration.rel=duration.freq/nrow(painters)
> cbind(duration.freq,duration.rel)
        duration.freq duration.rel
(5,10]             19    0.3518519
(10,15]            25    0.4629630
(15,20]            10    0.1851852
>
> duration.com = cumsum(duration.freq)
> cbind(duration.freq,duration.rel,duration.com)
        duration.freq duration.rel duration.com
(5,10]             19    0.3518519           19
(10,15]            25    0.4629630           44
(15,20]            10    0.1851852           54
>
> ogive = c(0,duration.com)
> ogive
         (5,10] (10,15] (15,20]
      0      19      44      54
> plot(ogive)
>
> plot(duration.freq)


Q-2

> library(MASS)
> data()
> cars
   speed dist
1      4    2
2      4   10
3      7    4
4      7   22
5      8   16
6      9   10
7     10   18
8     10   26
9     10   34
10    11   17
11    11   28
12    12   14
13    12   20
14    12   24
15    12   28
16    13   26
17    13   34
18    13   34
19    13   46
20    14   26
21    14   36
22    14   60
23    14   80
24    15   20
25    15   26
26    15   54
27    16   32
28    16   40
29    17   32
30    17   40
31    17   50
32    18   42
33    18   56
34    18   76
35    18   84
36    19   36
37    19   46
38    19   68
39    20   32
40    20   48
41    20   52
42    20   56
43    20   64
44    22   66
45    23   54
46    24   70
47    24   92
48    24   93
49    24  120
50    25   85
> val=cars$speed
> val
 [1]  4  4  7  7  8  9 10 10 10 11 11 12 12 12 12 13 13 13 13 14 14 14 14 15 15 15 16 16 17
[30] 17 17 18 18 18 18 19 19 19 20 20 20 20 20 22 23 24 24 24 24 25
> range(val)
[1]  4 25
> seq()
[1] 1
> breaks=seq(5,30,by=10)
> breaks
[1]  5 15 25
> val.cut=cut(val,breaks)
> val
 [1]  4  4  7  7  8  9 10 10 10 11 11 12 12 12 12 13 13 13 13 14 14 14 14 15 15 15 16 16 17
[30] 17 17 18 18 18 18 19 19 19 20 20 20 20 20 22 23 24 24 24 24 25
> val.freq=table(val)
> val
 [1]  4  4  7  7  8  9 10 10 10 11 11 12 12 12 12 13 13 13 13 14 14 14 14 15 15 15 16 16 17
[30] 17 17 18 18 18 18 19 19 19 20 20 20 20 20 22 23 24 24 24 24 25
> val.rel=val.freq/nrow(cars)
> val
 [1]  4  4  7  7  8  9 10 10 10 11 11 12 12 12 12 13 13 13 13 14 14 14 14 15 15 15 16 16 17
[30] 17 17 18 18 18 18 19 19 19 20 20 20 20 20 22 23 24 24 24 24 25
> cbind(val.rel)
   val.rel
4     0.04
7     0.04
8     0.02
9     0.02
10    0.06
11    0.04
12    0.08
13    0.08
14    0.08
15    0.06
16    0.04
17    0.06
18    0.08
19    0.06
20    0.10
22    0.02
23    0.02
24    0.08
25    0.02
> val.com=cumsum(val.freq)
> val
 [1]  4  4  7  7  8  9 10 10 10 11 11 12 12 12 12 13 13 13 13 14 14 14 14 15 15 15 16 16 17
[30] 17 17 18 18 18 18 19 19 19 20 20 20 20 20 22 23 24 24 24 24 25
> val.com=cumsum(val.freq)
> val.com
 4  7  8  9 10 11 12 13 14 15 16 17 18 19 20 22 23 24 25
 2  4  5  6  9 11 15 19 23 26 28 31 35 38 43 44 45 49 50
> dis=cbind(val.freq,val.rel,val.com)
> dis
   val.freq val.rel val.com
4         2    0.04       2
7         2    0.04       4
8         1    0.02       5
9         1    0.02       6
10        3    0.06       9
11        2    0.04      11
12        4    0.08      15
13        4    0.08      19
14        4    0.08      23
15        3    0.06      26
16        2    0.04      28
17        3    0.06      31
18        4    0.08      35
19        3    0.06      38
20        5    0.10      43
22        1    0.02      44
23        1    0.02      45
24        4    0.08      49
25        1    0.02      50
> ogive=c(0,val.rel,breaks)
> ogive
          4     7     8     9    10    11    12    13    14    15    16    17    18    19
 0.00  0.04  0.04  0.02  0.02  0.06  0.04  0.08  0.08  0.08  0.06  0.04  0.06  0.08  0.06
   20    22    23    24    25                  
 0.10  0.02  0.02  0.08  0.02  5.00 15.00 25.00
> plot(ogive)

Q-3

> npk
> stat=npk$yield
> range(stat)
[1] 44.2 69.5
> seq()
[1] 1
> breaks=seq(5,10,by=5)
> breaks
[1]  5 10
> stat.cut=cut(stat,breaks)
> stat.cut
 [1] <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA>
[16] <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA>
Levels: (5,10]
> stat.freq=table(stat)
> stat.freq
stat
44.2 45.5 46.8 48.8 49.5 49.8 51.5   52 53.2   55 55.5 55.8   56   57 57.2 58.5
   1    1    1    2    1    1    1    1    1    1    1    1    2    1    1    1
  59 59.8   62 62.8 69.5
   1    1    1    2    1
> stat.rel=stat.freq/nrow(npk)
> stat.rel
stat
      44.2       45.5       46.8       48.8       49.5       49.8       51.5
0.04166667 0.04166667 0.04166667 0.08333333 0.04166667 0.04166667 0.04166667
        52       53.2         55       55.5       55.8         56         57
0.04166667 0.04166667 0.04166667 0.04166667 0.04166667 0.08333333 0.04166667
      57.2       58.5         59       59.8         62       62.8       69.5
0.04166667 0.04166667 0.04166667 0.04166667 0.04166667 0.08333333 0.04166667
> cbind(stat.rel)
       stat.rel
44.2 0.04166667
45.5 0.04166667
46.8 0.04166667
48.8 0.08333333
49.5 0.04166667
49.8 0.04166667
51.5 0.04166667
52   0.04166667
53.2 0.04166667
55   0.04166667
55.5 0.04166667
55.8 0.04166667
56   0.08333333
57   0.04166667
57.2 0.04166667
58.5 0.04166667
59   0.04166667
59.8 0.04166667
62   0.04166667
62.8 0.08333333
69.5 0.04166667
> stat.com=cumsum(stat.freq)
> stat.com
44.2 45.5 46.8 48.8 49.5 49.8 51.5   52 53.2   55 55.5 55.8   56   57 57.2 58.5
   1    2    3    5    6    7    8    9   10   11   12   13   15   16   17   18
  59 59.8   62 62.8 69.5
  19   20   21   23   24
> dis=cbind(stat.freq,stat.rel,stat.com)
> dis
     stat.freq   stat.rel stat.com
44.2         1 0.04166667        1
45.5         1 0.04166667        2
46.8         1 0.04166667        3
48.8         2 0.08333333        5
49.5         1 0.04166667        6
49.8         1 0.04166667        7
51.5         1 0.04166667        8
52           1 0.04166667        9
53.2         1 0.04166667       10
55           1 0.04166667       11
55.5         1 0.04166667       12
55.8         1 0.04166667       13
56           2 0.08333333       15
57           1 0.04166667       16
57.2         1 0.04166667       17
58.5         1 0.04166667       18
59           1 0.04166667       19
59.8         1 0.04166667       20
62           1 0.04166667       21
62.8         2 0.08333333       23
69.5         1 0.04166667       24
> ogive=c(0,stat.rel,breaks)
> ogive
                   44.2        45.5        46.8        48.8        49.5
 0.00000000  0.04166667  0.04166667  0.04166667  0.08333333  0.04166667
       49.8        51.5          52        53.2          55        55.5
 0.04166667  0.04166667  0.04166667  0.04166667  0.04166667  0.04166667
       55.8          56          57        57.2        58.5          59
 0.04166667  0.08333333  0.04166667  0.04166667  0.04166667  0.04166667
       59.8          62        62.8        69.5                        
 0.04166667  0.04166667  0.08333333  0.04166667  5.00000000 10.00000000
> plot(ogive)

Measures of central tendency and variability

Q-1

> faithful
> var=faithful$waiting
> var
  [1] 79 54 74 62 85 55 88 85 51 85 54 84 78 47 83 52 62 84 52 79 51 47 78 69 74
 [26] 83 55 76 78 79 73 77 66 80 74 52 48 80 59 90 80 58 84 58 73 83 64 53 82 59
 [51] 75 90 54 80 54 83 71 64 77 81 59 84 48 82 60 92 78 78 65 73 82 56 79 71 62
 [76] 76 60 78 76 83 75 82 70 65 73 88 76 80 48 86 60 90 50 78 63 72 84 75 51 82
[101] 62 88 49 83 81 47 84 52 86 81 75 59 89 79 59 81 50 85 59 87 53 69 77 56 88
[126] 81 45 82 55 90 45 83 56 89 46 82 51 86 53 79 81 60 82 77 76 59 80 49 96 53
[151] 77 77 65 81 71 70 81 93 53 89 45 86 58 78 66 76 63 88 52 93 49 57 77 68 81
[176] 81 73 50 85 74 55 77 83 83 51 78 84 46 83 55 81 57 76 84 77 81 87 77 51 78
[201] 60 82 91 53 78 46 77 84 49 83 71 80 49 75 64 76 53 94 55 76 50 82 54 75 78
[226] 79 78 78 70 79 70 54 86 50 90 54 54 77 79 64 75 47 86 63 85 82 57 82 67 74
[251] 54 83 73 73 88 80 71 83 56 79 78 84 58 83 43 60 75 81 46 90 46 74
> mean(var)
[1] 70.89706
> median(var)
[1] 76
> sd(var)
[1] 13.59497
> var(var)
[1] 184.8233
> range(var)
[1] 43 96
> max(var)
[1] 96
> min(var)
[1] 43
> range=max(var)-min(var)
> range
[1] 53
> summary(var)
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max.
   43.0    58.0    76.0    70.9    82.0    96.0
> IQR(var)
[1] 24
> q1=quantile(var,.25)
> q1
25%
 58
> q3=quantile(var,.75)
> q3
75%
 82
> per32=quantile(var,.32)
> per32
  32%
62.72
> cv=(sd(var)/mean(var)*100)
> cv
[1] 19.17565
> bxlt=boxplot(var)
> stem(var)

  The decimal point is 1 digit(s) to the right of the |

  4 | 3
  4 | 55566666777788899999
  5 | 00000111111222223333333444444444
  5 | 555555666677788889999999
  6 | 00000022223334444
  6 | 555667899
  7 | 00001111123333333444444
  7 | 555555556666666667777777777778888888888888889999999999
  8 | 000000001111111111111222222222222333333333333334444444444
  8 | 55555566666677888888999
  9 | 00000012334
  9 | 6

Q-2

> ships
> st=ship$service
Error: object 'ship' not found
> st=ship$Year
Error: object 'ship' not found
> data()
> BOD
  Time demand
1    1    8.3
2    2   10.3
3    3   19.0
4    4   16.0
5    5   15.6
6    7   19.8
> var1=BOD$demand
> var1
[1]  8.3 10.3 19.0 16.0 15.6 19.8
> mean(var1)
[1] 14.83333
> meadian(var1)
Error in meadian(var1) : could not find function "meadian"
> median(var1)
[1] 15.8
> sd(var1)
[1] 4.630623
> var(var1)
[1] 21.44267
> range(var1)
[1]  8.3 19.8
> min(var1)
[1] 8.3
> range=max(var1)-min(var1)
> range
[1] 11.5
> summary(var1)
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max.
   8.30   11.62   15.80   14.83   18.25   19.80
> IQR(var1)
[1] 6.625
> qw=quantile(var1,.25)
> qw
   25%
11.625
> qw1=quantile(var1,.75)
> qw1
  75%
18.25
> per=quantile(var,.32)
Error in quantile.default(var, 0.32) :
  anyNA() applied to non-(list or vector) of type 'closure'
> per=quantile(var1,.32)
> per
  32%
13.48
> cv=(sd(var1)/mean(var1)*100)
> cv
[1] 31.21768
> bxlt=boxplot(var1)
> stem(var1)

  The decimal point is 1 digit(s) to the right of the |

  0 | 8
  1 | 0
  1 | 669
  2 | 0

> 
Q-3
> var1=coop$Conc
> var1
  [1] 0.29 0.33 0.33 0.32 0.34 0.31 0.13 0.14 0.16 0.11 0.14 0.13 0.68 0.71 0.86 0.76 0.72
 [18] 0.73 0.50 0.47 0.64 0.53 0.49 0.50 6.60 7.08 7.56 7.14 7.19 6.64 1.36 1.34 1.51 1.44
 [35] 1.52 1.30 1.06 0.88 1.01 1.09 0.87 1.02 0.40 0.40 0.43 0.36 0.42 0.40 0.22 0.22 0.24
 [52] 0.19 0.21 0.22 1.03 1.05 1.05 1.16 0.97 1.12 0.81 0.57 0.67 0.60 0.66 0.80 8.40 8.60
 [69] 7.54 8.50 8.74 8.22 2.12 2.44 1.49 1.70 1.73 1.64 1.50 1.07 1.23 0.93 1.32 1.25 0.40
 [86] 0.35 0.38 0.32 0.38 0.33 0.25 0.20 0.16 0.16 0.25 0.18 0.83 0.66 0.89 0.92 0.75 0.75
[103] 0.50 0.50 0.58 0.67 0.50 0.50 6.90 6.70 7.10 7.10 6.30 6.70 1.50 1.50 1.50 1.60 1.30
[120] 1.50 1.00 1.00 1.10 1.10 0.75 0.90 0.90 1.30 0.90 1.10 0.90 0.90 1.70 1.30 1.50 1.50
[137] 0.60 0.40 1.30 1.70 1.50 1.50 2.10 1.90 1.30 1.30 1.30 1.10 0.20 0.20 7.60 7.80 7.90
[154] 7.50 7.80 7.40 2.40 2.60 2.20 2.80 2.20 1.70 1.50 1.90 2.40 1.90 1.70 2.00 0.44 0.44
[171] 0.45 0.45 0.42 0.46 0.23 0.24 0.22 0.23 0.24 0.18 1.10 1.00 1.10 1.20 1.20 1.10 0.48
[188] 0.47 0.57 0.56 0.55 0.55 8.00 7.80 8.00 7.90 8.30 8.30 1.90 1.90 1.90 1.90 1.80 1.90
[205] 1.30 1.40 1.30 1.30 1.20 1.20 0.38 0.39 0.40 0.46 0.72 0.79 0.24 0.20 0.15 0.16 0.35
[222] 0.42 1.03 0.88 1.06 1.16 1.10 1.20 0.31 0.31 0.69 0.73 1.10 0.90 7.70 6.90 9.40 9.90
[239] 9.20 9.00 1.70 1.80 2.00 2.10 1.50 1.50 1.50 1.50 1.30 1.40 1.50 1.80
> mean(var1)
[1] 1.921508
> median(var1)
[1] 1.06
> sd(var1)
[1] 2.473207
> var(var1)
[1] 6.116755
> range(var1)
[1] 0.11 9.90
> max(var1)
[1] 9.9
> min(var2)
Error: object 'var2' not found
> range=max(var1)-min(var1)
> range
[1] 9.79
> summary(var1)
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max.
 0.1100  0.4675  1.0600  1.9215  1.7000  9.9000
> IQR(var1)
[1] 1.2325
> c1=quantile(var1,.25)
> c1
   25%
0.4675
> c2=quantile(var1,.75)
> c2
75%
1.7
> per1=quantile(var1,.32)
> per1
32%
0.6
> cv=(sd(var1)/mean(var1)*100)
> cv
[1] 128.7118
> bxlt=boxplot(var1)
> stem(var1)

  The decimal point is at the |

  0 | 11111222222222222222222222223333333333334444444444444444444
  0 | 55555555555555566666666677777777777888888889999999999999
  1 | 000000001111111111111111222222223333333333333334444
  1 | 55555555555555555566777777788899999999
  2 | 0011122444
  2 | 68
  3 |
  3 |
  4 |
  4 |
  5 |
  5 |
  6 | 3
  6 | 667799
  7 | 111124
  7 | 5566788899
  8 | 002334
  8 | 567
  9 | 024
  9 | 9
> 
Binomial distribution

Q-1

> n=20
> x=5
> p=0.5
> ans=choose(n,x)*p^x*(1-p)^(n-x)
> ans
[1] 0.01478577
> dbinom(5,20,.5)
[1] 0.01478577
> ans=choose(20,5)
> ans
[1] 15504
> ans=(choose(20,0)*.5^0*.5^20)+(choose(20,1)*.5^1*.5^19)+(choose(20,2)*.5^2*.5^18)
> ans
[1] 0.0002012253
> ans=dbinom(0,20,.5)+dbinom(1,20,.5)+dbinom(2,20,.5)
> ans
[1] 0.0002012253
> ans=pbinom(2,20,.5)
> ans
[1] 0.0002012253
> ans=dbinom(2,20,.5)
> ans
[1] 0.0001811981
> ans=qbinom(0.0001811981,20,.5)
> ans
[1] 2

Q-2

> n=10
> x=6
> p=0.65
> ans=choose(n,x)*p^x*(1-p)^(n-x)
> ans
[1] 0.2376685
> dbinom(6,10,.65)
[1] 0.2376685
> ans=choose(10,6)
> ans
[1] 210
> pbinom(2,10,.65)
[1] 0.004821265
> qbinom(0.2376685
+ ,10,.65)
[1] 5

Q-3

> n=15
> x=8
> p=0.80
> ans=choose(n,x)*p^x*(1-p)^(n-x)
> ans
[1] 0.01381906
> dbinom(8,15,.80)
[1] 0.01381906
> pbinom(8,15,.80)
[1] 0.01805881
> qbinom( 0.01381906
+ ,15,.80)
[1] 8





No comments:

Post a Comment