数据统计与分析基础实验三:常规数学统计计算(R语言,还没写完)

数据统计与分析基础实验三:常规数学统计计算

      • 1、随机生成一个10x15的高斯矩阵,均值为自己学号后两位,方差为1。对该矩阵分别进行LU、QR、奇异值,并展示分解结果。
        • LU
        • QR
        • 奇异值
      • 2、利用软件求解优化问题:min Z = - X1 - 0.8X2 - 1.2X3, 约束:X1 –X2 + X3 <= 30, 3X1 + 2X2 + 4X3 <=42, 3X1 + 2X2 <= 30, X1, X2 , X3 >=0。并找到其中有效约束。
      • 3、对于函数f(x) = (x2-5x+3)exp(-4x)cosx, x = 0: 0.1:1,进行三种方式插值,并将插值曲线与原曲线绘制在同一个Figure窗口。
      • 4、统计自己过去12个月实际生活花费的数值,并拟合成一条一次、二次、三次曲线,三条曲线分别用不同颜色和线型展示在同一张图里。
      • 5、求解三重积分∫(-0.5,1)∫(0,0.5)∫(-0.5pi,pi)(y sinx exp(x)+z cosx x2)dxdydz.
      • 6、求微分方程 xy’+ y – exp(x) = 0,在初始条件y(1) = 2 exp下的特解,并画出解函数的图形。
      • 7、 某人进行射击,及每次命中的概率为0.1,独立射击50次,求击中10次以上且40次以下的概率。
      • 8、假设自己过去12个月实际生活花费的数值服从正态分布,请求出其均值和方差的极大似然估计。

1、随机生成一个10x15的高斯矩阵,均值为自己学号后两位,方差为1。对该矩阵分别进行LU、QR、奇异值,并展示分解结果。

LU

> X<-matrix(rnorm(150,79,1),nrow=10,ncol=15,byrow=T)
> #均值79,150个,正态(高斯)分布
> X
          [,1]     [,2]     [,3]     [,4]     [,5]     [,6]     [,7]     [,8]     [,9]    [,10]    [,11]    [,12]    [,13]    [,14]    [,15]
 [1,] 79.28764 79.28067 79.06171 77.86130 79.92227 78.97803 80.19302 78.09195 80.12844 79.33108 79.07045 81.65337 77.83014 79.16602 76.44480
 [2,] 78.84768 78.64431 79.12125 78.62161 79.20040 78.80970 78.73790 79.90102 79.35878 79.00298 79.69092 79.28335 80.06084 76.60801 78.48222
 [3,] 79.96133 79.44971 78.41336 77.65514 78.49294 77.61689 79.46074 78.41758 78.29983 78.08997 81.00809 78.36508 79.34868 78.78832 76.39192
 [4,] 77.75511 79.42457 79.92943 79.68850 77.51813 79.90277 79.25886 78.71600 77.85925 79.97145 79.44708 79.05540 79.35358 80.32224 77.71266
 [5,] 79.09960 77.77367 80.70951 80.78063 78.81128 79.11045 78.52318 79.50448 79.10117 78.30584 79.34353 77.81714 80.09034 78.44839 80.20928
 [6,] 77.32727 78.23094 79.61353 80.92026 77.00957 77.93693 80.35393 80.52509 77.61259 80.49315 78.47708 77.24535 79.15108 78.19794 77.97894
 [7,] 79.78001 78.23899 78.05903 81.42659 79.24841 78.22265 79.27916 78.83118 77.72174 77.34338 77.36072 79.11792 77.75593 79.01005 77.64143
 [8,] 79.14777 79.58133 80.26682 79.91078 79.82839 79.38519 80.49733 77.77436 77.41137 78.69928 77.23665 80.30657 79.12233 80.41864 78.32603
 [9,] 78.28875 78.58956 78.79957 78.26176 80.27090 78.26865 79.02158 79.30549 79.33774 78.56470 78.68895 79.66592 79.05017 80.39068 77.38571
[10,] 78.58806 78.09882 79.44993 80.73510 79.12248 78.46254 79.49634 80.48909 78.09370 78.71434 78.56228 79.03188 77.47336 78.16855 78.46260
> expand(lux<-lu(X))
$L
10 x 10 Matrix of class "dtrMatrix" (unitriangular)
      [,1]         [,2]         [,3]         [,4]         [,5]         [,6]         [,7]         [,8]         [,9]         [,10]       
 [1,]  1.000000000            .            .            .            .            .            .            .            .            .
 [2,]  0.972408865  1.000000000            .            .            .            .            .            .            .            .
 [3,]  0.989223152 -0.378332467  1.000000000            .            .            .            .            .            .            .
 [4,]  0.997732293 -0.475577388  0.347079743  1.000000000            .            .            .            .            .            .
 [5,]  0.979082547  0.369980937  0.146700242 -0.031699053  1.000000000            .            .            .            .            .
 [6,]  0.967058284  0.645343280  0.310732760  0.350660645 -0.179429136  1.000000000            .            .            .            .
 [7,]  0.991574779  0.230892682  0.101340905 -0.165944893  0.652181982 -0.445637838  1.000000000            .            .            .
 [8,]  0.989825531  0.433776199  0.232757310 -0.013889100  0.452607506  0.183494824  0.201566422  1.000000000            .            .
 [9,]  0.982825740  0.006272751  0.520631403  0.374560254  0.280494778  0.301510971  0.065332617 -0.260755584  1.000000000            .
[10,]  0.986072576  0.138960838  0.284267601 -0.026876671  0.433385293 -0.299111830  0.199503762 -0.648373256  0.874030464  1.000000000

$U
10 x 15 Matrix of class "dgeMatrix"
          [,1]     [,2]      [,3]      [,4]       [,5]        [,6]       [,7]       [,8]       [,9]      [,10]      [,11]      [,12]      [,13]
 [1,] 79.96133 79.44971 78.413357 77.655136 78.4929396 77.61689055 79.4607439 78.4175822 78.2998290 78.0899688 81.0080909 78.3650780 79.3486826
 [2,]  0.00000  2.16696  3.679591  4.175960  1.1909035  4.42741917  1.9905305  2.4620458  1.7198043  4.0360731  0.6740984  2.8525048  2.1942145
 [3,]  0.00000  0.00000  4.533309  5.542276  1.6148091  4.00506056  0.6718547  2.8634660  2.2958260  2.5844099 -0.5365188  1.3757839  2.4269316
 [4,]  0.00000  0.00000  0.000000  4.009931  0.9393688  1.49727984  0.7120774  0.7684726 -0.3794612  0.4529684 -2.9568653  1.8096275 -1.2116282
 [5,]  0.00000  0.00000  0.000000  0.000000  2.7721016  0.09716843  0.4105032  1.2215825  1.6906259  0.2501340 -0.8890861  1.7401994  0.1550007
 [6,]  0.00000  0.00000  0.000000  0.000000  0.0000000 -1.73243541  1.8413765  2.1617961  0.5052528  1.4539308  0.7465506 -1.1289148  0.6988155
 [7,]  0.00000  0.00000  0.000000  0.000000  0.0000000  0.00000000  1.5450996 -0.2293943  0.9181463  1.2651940 -0.9345461  1.8127753 -1.5933193
 [8,]  0.00000  0.00000  0.000000  0.000000  0.0000000  0.00000000  0.0000000 -2.4724941 -2.4204228 -1.5771919 -2.7020287  0.2605034 -0.8297543
 [9,]  0.00000  0.00000  0.000000  0.000000  0.0000000  0.00000000  0.0000000  0.0000000 -1.2429997 -0.5774546 -0.2911517  0.4024430 -1.7024896
[10,]  0.00000  0.00000  0.000000  0.000000  0.0000000  0.00000000  0.0000000  0.0000000  0.0000000  0.2734360 -0.9119530 -0.3654972  2.1996718
           [,14]      [,15]
 [1,] 78.7883242 76.3919239
 [2,]  3.7077790  3.4284784
 [3,]  1.9119272  5.9377238
 [4,]  1.5001369  0.9923843
 [5,]  1.6456686  0.4836298
 [6,] -1.2126053 -0.2153066
 [7,] -1.3730681 -0.9435328
 [8,]  0.1538485 -0.1333075
 [9,] -0.8133704 -0.1457831
[10,] -2.0927327  0.9718066

$P
10 x 10 sparse Matrix of class "pMatrix"
                         
 [1,] . . . . . . | . . .
 [2,] . . . . . . . . . |
 [3,] | . . . . . . . . .
 [4,] . | . . . . . . . .
 [5,] . . | . . . . . . .
 [6,] . . . . . | . . . .
 [7,] . . . | . . . . . .
 [8,] . . . . . . . | . .
 [9,] . . . . | . . . . .
[10,] . . . . . . . . | .

> 
> 

QR

> #qr
> qr(X)
$qr
              [,1]         [,2]          [,3]          [,4]          [,5]         [,6]         [,7]          [,8]         [,9]        [,10]
 [1,] -249.2264887 -248.9607965 -250.87989039 -251.65073888 -249.64198733 -248.7574082 -251.3293317 -250.28346791 -248.2074393 -249.3149401
 [2,]    0.3163696    2.9132348    2.61145014    0.98187200    0.66391915    2.6653878    2.7370520    1.73838602    1.3303129    4.1686201
 [3,]    0.3208380    0.1528378    3.27612404    3.73595046    0.38131165    1.9572461    0.8261335    2.73696991    1.0142605    2.0199458
 [4,]    0.3119857   -0.5952122   -0.09557788   -3.73940084    0.54250670   -0.2069258   -1.0602672   -1.60591604    1.2522346   -0.6952599
 [5,]    0.3173804    0.4326068   -0.72444665   -0.26124951    2.61357716    0.4594159    0.3103866    0.51819459    1.2394289   -0.0248041
 [6,]    0.3102691   -0.3322246   -0.33575981    0.40149267    0.26088107    1.2910551   -1.0457994   -0.93361945    0.4090450   -0.3402466
 [7,]    0.3201105    0.5062414    0.23564686    0.82493520   -0.34269746    0.2816665   -1.1664586    0.44868875   -0.5126468   -0.7833503
 [8,]    0.3175737   -0.1713743   -0.10272400   -0.03793401   -0.05479495    0.1943184   -0.2907023    2.84942678    1.9459087    1.5591726
 [9,]    0.3141269   -0.1255633    0.04600547   -0.06600955   -0.62805452    0.2372021   -0.8841201    0.45650549   -1.1222655   -0.4275769
[10,]    0.3153279    0.1455470   -0.27254469    0.26073528   -0.12473436    0.4306166   -0.1045288    0.03888371   -0.4923620   -0.1754419
             [,11]        [,12]        [,13]         [,14]        [,15]
 [1,] -249.4582707 -250.3066465 -249.5607478 -249.65236726 -246.3336239
 [2,]    2.0351688    2.2365590    2.4204124    3.32299381    1.0048710
 [3,]    0.5704595   -0.4497459    2.0937964    0.55917724    4.1518873
 [4,]    1.2519630    0.5755954    0.6013972   -0.73328905   -0.6995292
 [5,]   -1.4514335    2.3415186   -0.6656064    1.21516467    0.3225719
 [6,]   -0.2158874    1.0951689   -0.2280997   -0.03147505    0.2286951
 [7,]    0.8606732   -1.4187992    1.4747500    0.67411670    0.8499550
 [8,]    2.4714592   -0.2054328    0.8740892   -1.75024932    0.5288189
 [9,]   -0.5756725    0.2379873   -0.7826350   -1.45217589    0.2017076
[10,]    0.5851269    0.2345101   -1.4113524    1.34273826   -0.6235301

$rank
[1] 10

$qraux
 [1] 1.3181349 1.0473455 1.4591606 1.1274956 1.6336291 1.8007552 1.3505675 1.8888705 1.8703905 0.1754419 0.5851269 0.2345101 1.4113524 1.3427383
[15] 0.6235301

$pivot
 [1]  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15

attr(,"class")
[1] "qr"
> qr.Q(qr(X))
            [,1]        [,2]        [,3]        [,4]        [,5]       [,6]         [,7]        [,8]        [,9]       [,10]
 [1,] -0.3181349  0.02662043 -0.25074081  0.34416189  0.15062377  0.2025038 -0.772087790  0.04147118 -0.18435474  0.14574560
 [2,] -0.3163696 -0.04095622 -0.04351398  0.21132999  0.05754902  0.2494406  0.137117711  0.48787289  0.34300094 -0.64161956
 [3,] -0.3208380 -0.14635828 -0.51775951  0.26901673 -0.55596151 -0.3713061  0.237859373  0.01943516  0.02362004  0.17528018
 [4,] -0.3119857  0.60151295  0.02675873 -0.13009647 -0.26997008  0.5696713  0.239325984 -0.04644029 -0.06441149  0.24942782
 [5,] -0.3173804 -0.42619719  0.67095765  0.31464218 -0.21570769  0.1136136  0.096211493 -0.12146693 -0.28870712  0.04051213
 [6,] -0.3102691  0.33849067  0.27145230 -0.39961870 -0.21352456 -0.5134559 -0.282128549  0.22972943 -0.23105708 -0.24654914
 [7,] -0.3201105 -0.49977655 -0.28848338 -0.65225153  0.05014704  0.2567901  0.005417173 -0.16316611 -0.17399061 -0.11711886
 [8,] -0.3175737  0.17778791  0.03958669  0.08806974  0.14070941 -0.1637352 -0.035062654 -0.77036634  0.37964791 -0.26977852
 [9,] -0.3141269  0.13190721 -0.10775810  0.13784300  0.66206685 -0.2238934  0.422849736  0.08067166 -0.41086808  0.10358143
[10,] -0.3153279 -0.13917880  0.21487796 -0.19160713  0.19812782 -0.1222875 -0.048076658  0.25219145  0.60307538  0.56079504
> qr.R(qr(X))
           [,1]        [,2]        [,3]        [,4]         [,5]         [,6]         [,7]         [,8]         [,9]        [,10]
 [1,] -249.2265 -248.960796 -250.879890 -251.650739 -249.6419873 -248.7574082 -251.3293317 -250.2834679 -248.2074393 -249.3149401
 [2,]    0.0000    2.913235    2.611450    0.981872    0.6639192    2.6653878    2.7370520    1.7383860    1.3303129    4.1686201
 [3,]    0.0000    0.000000    3.276124    3.735950    0.3813116    1.9572461    0.8261335    2.7369699    1.0142605    2.0199458
 [4,]    0.0000    0.000000    0.000000   -3.739401    0.5425067   -0.2069258   -1.0602672   -1.6059160    1.2522346   -0.6952599
 [5,]    0.0000    0.000000    0.000000    0.000000    2.6135772    0.4594159    0.3103866    0.5181946    1.2394289   -0.0248041
 [6,]    0.0000    0.000000    0.000000    0.000000    0.0000000    1.2910551   -1.0457994   -0.9336194    0.4090450   -0.3402466
 [7,]    0.0000    0.000000    0.000000    0.000000    0.0000000    0.0000000   -1.1664586    0.4486888   -0.5126468   -0.7833503
 [8,]    0.0000    0.000000    0.000000    0.000000    0.0000000    0.0000000    0.0000000    2.8494268    1.9459087    1.5591726
 [9,]    0.0000    0.000000    0.000000    0.000000    0.0000000    0.0000000    0.0000000    0.0000000   -1.1222655   -0.4275769
[10,]    0.0000    0.000000    0.000000    0.000000    0.0000000    0.0000000    0.0000000    0.0000000    0.0000000   -0.1754419
             [,11]        [,12]        [,13]         [,14]        [,15]
 [1,] -249.4582707 -250.3066465 -249.5607478 -249.65236726 -246.3336239
 [2,]    2.0351688    2.2365590    2.4204124    3.32299381    1.0048710
 [3,]    0.5704595   -0.4497459    2.0937964    0.55917724    4.1518873
 [4,]    1.2519630    0.5755954    0.6013972   -0.73328905   -0.6995292
 [5,]   -1.4514335    2.3415186   -0.6656064    1.21516467    0.3225719
 [6,]   -0.2158874    1.0951689   -0.2280997   -0.03147505    0.2286951
 [7,]    0.8606732   -1.4187992    1.4747500    0.67411670    0.8499550
 [8,]    2.4714592   -0.2054328    0.8740892   -1.75024932    0.5288189
 [9,]   -0.5756725    0.2379873   -0.7826350   -1.45217589    0.2017076
[10,]    0.5851269    0.2345101   -1.4113524    1.34273826   -0.6235301
> 

奇异值

> svd(X)
$d
 [1] 966.652468   6.713068   5.245613   4.380018   3.447728   3.198833   2.327248   1.845607   1.370596   1.218602

$u
            [,1]        [,2]         [,3]         [,4]        [,5]        [,6]         [,7]        [,8]        [,9]        [,10]
 [1,] -0.3168723 -0.57937235  0.002979980 -0.008681674 -0.37697765  0.26306893  0.232153894 -0.25872547  0.34427080 -0.336394490
 [2,] -0.3163500  0.04150666  0.482878205  0.303703801 -0.08451119  0.31090003  0.344766011  0.24128901 -0.53646806  0.064106013
 [3,] -0.3151237 -0.28318087  0.467198900 -0.093375225  0.21230184 -0.69448688  0.043880214  0.07650871  0.17781076  0.163499530
 [4,] -0.3167697  0.06392744 -0.012046386 -0.615167748  0.22714076  0.12772421 -0.005032644 -0.55148555 -0.36940088  0.092025602
 [5,] -0.3172203  0.40167816  0.139920732  0.327425310  0.52456230  0.22086891 -0.033700656 -0.20233882  0.43355336 -0.239263161
 [6,] -0.3154828  0.51833140  0.061093030 -0.422739794 -0.43315545 -0.10163253 -0.032504854  0.35501995  0.15191560 -0.318174446
 [7,] -0.3149368  0.04307530 -0.467427984  0.385969751 -0.05324131 -0.46212563 -0.001099071 -0.16315277 -0.39073682 -0.368520985
 [8,] -0.3173059 -0.15035261 -0.534452333 -0.158820384  0.34718146  0.12884198  0.348073878  0.49557174  0.09839185  0.228658864
 [9,] -0.3162259 -0.27470442  0.005496748  0.040070129  0.04117424  0.21455494 -0.835467646  0.25457048 -0.11103814  0.005650308
[10,] -0.3159801  0.21997739 -0.144676299  0.242528129 -0.40770889 -0.01428239 -0.062729940 -0.24668684  0.19968327  0.707758434

$v
            [,1]         [,2]         [,3]        [,4]         [,5]        [,6]        [,7]         [,8]         [,9]       [,10]
 [1,] -0.2578093 -0.173640210 -0.001620601  0.36262153  0.143726579 -0.50436129  0.28066180 -0.028986862  0.107725634 -0.12838301
 [2,] -0.2575593 -0.194319425  0.012362407 -0.23722406  0.041589361 -0.20477910  0.21392978  0.104067972 -0.275214702  0.20928805
 [3,] -0.2595626  0.177645080 -0.033756852 -0.13048871  0.210802919  0.28917137  0.17108880 -0.004265629  0.574853804  0.22521956
 [4,] -0.2603538  0.506701763 -0.430105441  0.14234953 -0.107864937 -0.28237337  0.04785501 -0.256441673 -0.151989166 -0.28603931
 [5,] -0.2582515 -0.290581367 -0.145057190  0.43571984 -0.007074256  0.11640779 -0.24627673  0.340318508 -0.006284875  0.24768988
 [6,] -0.2573604  0.001315954 -0.093617830 -0.10206344  0.163252291  0.27637113  0.23346999 -0.397968939 -0.322793003  0.08392678
 [7,] -0.2600149 -0.051481267 -0.156529915 -0.21859585 -0.307313194 -0.23600221  0.22261558  0.391383111  0.373639023 -0.07915543
 [8,] -0.2589443  0.326835635  0.176119143  0.13836495 -0.459579067 -0.05897397 -0.38549196  0.097211193 -0.215145130  0.34615684
 [9,] -0.2567793 -0.183283084  0.276107311  0.25357765 -0.163874198  0.27036382 -0.21729941 -0.198844987  0.212489812 -0.60909318
[10,] -0.2579539  0.107823095  0.116261322 -0.45191493 -0.371736360  0.20558543  0.06680208  0.057552815 -0.023965688 -0.15933395
[11,] -0.2580721 -0.064291840  0.596544130 -0.07282704  0.068127632 -0.32016806 -0.04726648 -0.396698286  0.123829490  0.25595053
[12,] -0.2589458 -0.450478062 -0.210355458  0.08839535 -0.232207427  0.27777863  0.23527099 -0.133219585 -0.215831710  0.08051379
[13,] -0.2581900  0.120715041  0.313154312 -0.09597329  0.432147547  0.04841573  0.01401577  0.499230173 -0.376854848 -0.33097692
[14,] -0.2582826 -0.207966050 -0.372559689 -0.37862193  0.314927689 -0.14222153 -0.64649306 -0.126270167  0.079583316 -0.03821155
[15,] -0.2548542  0.373856977 -0.040697299  0.27116466  0.282222108  0.27133392  0.05622709  0.050781973  0.113884408  0.18250772

> 

2、利用软件求解优化问题:min Z = - X1 - 0.8X2 - 1.2X3, 约束:X1 –X2 + X3 <= 30, 3X1 + 2X2 + 4X3 <=42, 3X1 + 2X2 <= 30, X1, X2 , X3 >=0。并找到其中有效约束。

> obj<-c(-1,-0.8,-1.2) #z的系数
> mat<-matrix(c(1,3,3,-1,2,2,1,4,0),nrow=3)#约束的系数矩阵
> dir<-c("<=","<=","<=")
> rhs<-c(30,42,30)
> max<-FALSE #计算最小值
> types<-c("I","I","I") # 目标变量类型为整数
> Rglpk_solve_LP(obj,mat,dir,rhs,types=types,max = max)
$optimum #目标函数在最优处的值
[1] -15.6

$solution #最优系数的向量
[1]  0 15  3

$status #找到最佳解决方案,返回0
[1] 0

$solution_dual # variable reduced cost, if available (NA otherwise).
[1] NA

$auxiliary 
#?辅助? a list with two vectors each containing the values
# of the auxiliary variable associated with the respective constraint
# at solution, primal and dual (if available, NA otherwise).
$auxiliary$primal
[1] -12  42  30

$auxiliary$dual
[1] NA


$sensitivity_report
[1] NA

> 

3、对于函数f(x) = (x2-5x+3)exp(-4x)cosx, x = 0: 0.1:1,进行三种方式插值,并将插值曲线与原曲线绘制在同一个Figure窗口。

4、统计自己过去12个月实际生活花费的数值,并拟合成一条一次、二次、三次曲线,三条曲线分别用不同颜色和线型展示在同一张图里。

money<-c(255,356,689,1245,1006,1165,547,897,1357,1024,975,651)
month<-c(1:12)
cost<-data.frame(month,money)
g4= ggplot(cost)+
    geom_point(aes(x=month,y=money,color="point"))+
    geom_smooth(aes(x=month,y=money,color="x"),alpha = 0,method='lm',span=1,formula = y~I(poly(x,1)))+
    geom_smooth(aes(x=month,y=money,color="x^3"),alpha=0,method='lm',formula = y~I(poly(x,3)),span=1)+
    geom_smooth(aes(x=month,y=money,color="x^2"),alpha=0,method='lm',formula = y~I(poly(x,2)),span=1)+
    coord_cartesian(xlim = c(1,12),ylim=c(0,1500))+
    scale_x_continuous(breaks = seq(1,12,by=1))+
    scale_y_continuous(breaks = seq(0,1500,by=100))
g4

数据统计与分析基础实验三:常规数学统计计算(R语言,还没写完)_第1张图片

5、求解三重积分∫(-0.5,1)∫(0,0.5)∫(-0.5pi,pi)(y sinx exp(x)+z cosx x2)dxdydz.

> f<-function(x,y,z){
     
+     y*sin(x)*exp(x)+z*cos(x)*x^2
+ }
> arr<-array(1:1000)
> x1<--0.5*pi
> x2<-pi
> y1<-0
> y2<-0.5
> z1<--0.5
> z2<-1
> v<-(x2-x1)*(y2-y1)*(z2-z1)#空间体积
> for(i in 1:1000){
     
+     r1<-runif(10^6,min = x1,max = x2)#生成随机数
+     r2<-runif(10^6,min = y1,max = y2)
+     r3<-runif(10^6,min = z1,max = z2)
+     h<-f(r1,r2,r3)
+     out<-v*mean(h)
+     arr[i]<-out;
+ }
> show<-mean(arr)
> show
[1] 1.098548
> show
[1] 1.098548
> 

6、求微分方程 xy’+ y – exp(x) = 0,在初始条件y(1) = 2 exp下的特解,并画出解函数的图形。

#deSolve包到底怎么用啊啊啊啊啊啊啊啊啊啊

7、 某人进行射击,及每次命中的概率为0.1,独立射击50次,求击中10次以上且40次以下的概率。

> show<-0
> for(x in 10:40){
     
+ temp<-dbinom(x,size = 50,prob = 0.1)
+ show=show+temp
+ print(paste("temp:",temp))
+ print(paste("show:",show))
+ }
[1] "temp: 0.0151833341172624"
[1] "show: 0.0151833341172624"
[1] "temp: 0.00613468045141914"
[1] "show: 0.0213180145686815"
[1] "temp: 0.00221530127412358"
[1] "show: 0.0235333158428051"
[1] "temp: 0.000719499559117061"
[1] "show: 0.0242528154019222"
[1] "temp: 0.00021128161656612"
[1] "show: 0.0244640970184883"
[1] "temp: 5.63417644176324e-05"
[1] "show: 0.0245204387829059"
[1] "temp: 1.36941788515078e-05"
[1] "show: 0.0245341329617574"
[1] "temp: 3.04315085589064e-06"
[1] "show: 0.0245371761126133"
[1] "temp: 6.19901100274016e-07"
[1] "show: 0.0245377960137136"
[1] "temp: 1.16004884261805e-07"
[1] "show: 0.0245379120185979"
[1] "temp: 1.99786189561996e-08"
[1] "show: 0.0245379319972168"
[1] "temp: 3.17120935812692e-09"
[1] "show: 0.0245379351684262"
[1] "temp: 4.6447005750344e-10"
[1] "show: 0.0245379356328962"
[1] "temp: 6.28268676816245e-11"
[1] "show: 0.0245379356957231"
[1] "temp: 7.85335846020313e-12"
[1] "show: 0.0245379357035765"
[1] "temp: 9.0749919984569e-13"
[1] "show: 0.024537935704484"
[1] "temp: 9.69550427185568e-14"
[1] "show: 0.0245379357045809"
[1] "temp: 9.57580668825249e-15"
[1] "show: 0.0245379357045905"
[1] "temp: 8.73982356467482e-16"
[1] "show: 0.0245379357045914"
[1] "temp: 7.36690108899799e-17"
[1] "show: 0.0245379357045914"
[1] "temp: 5.72981195810956e-18"
[1] "show: 0.0245379357045914"
[1] "temp: 4.1073920846663e-19"
[1] "show: 0.0245379357045914"
[1] "temp: 2.70973783363401e-20"
[1] "show: 0.0245379357045914"
[1] "temp: 1.64226535371762e-21"
[1] "show: 0.0245379357045914"
[1] "temp: 9.12369640954217e-23"
[1] "show: 0.0245379357045914"
[1] "temp: 4.6342584937357e-24"
[1] "show: 0.0245379357045914"
[1] "temp: 2.14549004339616e-25"
[1] "show: 0.0245379357045914"
[1] "temp: 9.02007826052439e-27"
[1] "show: 0.0245379357045914"
[1] "temp: 3.42868471891285e-28"
[1] "show: 0.0245379357045914"
[1] "temp: 1.17219990390182e-29"
[1] "show: 0.0245379357045914"
[1] "temp: 3.5817219285889e-31"
[1] "show: 0.0245379357045914"
> print(show)
[1] 0.02453794

8、假设自己过去12个月实际生活花费的数值服从正态分布,请求出其均值和方差的极大似然估计。


你可能感兴趣的:(数据统计与分析基础,线性代数,矩阵,概率论)