根据概率分布计算矩

时间:2017-05-26 07:45:54

标签: r

我有一个概率密度分布,我计算得将结束概率除以回报的差异:

deltaR <- c(NA)
for (i in 2:204) { 
  deltaR[i - 1] = (R[i + 1] - R[i - 1]) / 2 
}
for (i in 1:204) { 
  probability_density[i] = End_Probabilities[i + 1] / deltaR[i]
}

现在我应该能够通过将-Inf与Inf的概率密度函数相加并将其乘以x ** j来计算矩(理论上)。如何在R中实现最后一步?我看一下包装时刻,这需要另一种输入,而不是密度功能。这是我计算的概率密度:

c(1.060127e-01, 7.808639e-02, 5.351772e-02, 3.271984e-02, 1.653464e-02, 6.228544e-03, 1.406439e-03, 9.808728e-05, 2.659169e-09, 1.526135e-05,
2.540583e-04, 9.029513e-04, 1.695233e-03, 2.376100e-03, 2.854467e-03, 3.152196e-03, 3.332074e-03, 3.391327e-03, 3.314459e-03, 3.103407e-03,
2.782234e-03, 2.421864e-03, 2.095342e-03, 1.866990e-03, 1.799232e-03, 1.995382e-03, 2.643171e-03, 4.140963e-03, 7.222687e-03, 1.290895e-02,
2.261961e-02, 3.847810e-02, 6.267389e-02, 9.368153e-02, 1.257818e-01, 1.508366e-01, 1.633405e-01, 1.614039e-01, 1.503522e-01, 1.369496e-01,
1.256595e-01, 1.203709e-01, 1.266565e-01, 1.518232e-01, 2.052942e-01, 3.027602e-01, 4.690844e-01, 7.386214e-01, 1.145504e+00, 1.716563e+00,
2.443353e+00, 3.283689e+00, 4.184745e+00, 5.080073e+00, 5.893442e+00, 6.546659e+00, 6.980054e+00, 7.150451e+00, 7.039760e+00, 6.653884e+00,
6.033344e+00, 5.240736e+00, 4.364490e+00, 3.488565e+00, 2.677145e+00, 1.975665e+00, 1.411421e+00, 9.921453e-01, 7.066775e-01, 5.266718e-01,
4.271196e-01, 3.924719e-01, 4.133705e-01, 4.695568e-01, 5.348714e-01, 5.759546e-01, 5.631329e-01, 5.025344e-01, 4.130699e-01, 3.141471e-01,
2.215556e-01, 1.447194e-01, 8.790208e-02, 5.098624e-02, 3.014762e-02, 1.910260e-02, 1.344742e-02, 1.065112e-02, 9.321387e-03, 8.835730e-03,
8.816743e-03, 8.942431e-03, 8.948472e-03, 8.794572e-03, 8.501278e-03, 8.093566e-03, 7.602140e-03, 7.072520e-03, 6.550003e-03, 6.074361e-03,
5.673101e-03, 5.343198e-03, 5.075543e-03, 4.861257e-03, 4.688752e-03, 4.544127e-03, 4.404867e-03, 4.250920e-03, 4.077948e-03, 3.889586e-03,
3.704711e-03, 3.541290e-03, 3.403317e-03, 3.289065e-03, 3.187416e-03, 3.087250e-03, 2.984974e-03, 2.880152e-03, 2.777254e-03, 2.680905e-03, 2.592347e-03, 2.511498e-03, 2.436366e-03, 2.364864e-03, 2.296123e-03, 2.229745e-03, 2.165964e-03, 2.105085e-03, 2.047108e-03, 1.991933e-03, 1.939349e-03, 1.889138e-03, 1.841124e-03, 1.795147e-03, 1.751063e-03, 1.708734e-03, 1.668043e-03, 1.628947e-03, 1.591417e-03, 1.555428e-03,
1.520928e-03, 1.487760e-03, 1.455745e-03, 1.424711e-03, 1.394546e-03, 1.365347e-03, 1.337263e-03, 1.310441e-03, 1.284943e-03, 1.260516e-03,
1.236840e-03, 1.213614e-03, 1.190628e-03, 1.167988e-03, 1.145885e-03, 1.124552e-03, 1.104209e-03, 1.084995e-03, 1.067065e-03, 1.050736e-03,
1.035943e-03, 1.020968e-03, 1.003863e-03, 9.833325e-04, 9.592756e-04, 9.355316e-04, 9.172070e-04, 9.110385e-04, 9.202415e-04, 9.318257e-04,
9.283292e-04, 8.961524e-04, 8.376603e-04, 7.670913e-04, 7.256675e-04, 7.485672e-04, 8.356126e-04, 9.654478e-04, 1.042324e-03, 9.663562e-04,
7.592500e-04, 5.156526e-04, 3.910638e-04, 4.753052e-04, 8.290892e-04, 1.517836e-03, 2.148325e-03, 2.052454e-03, 1.269326e-03, 4.111317e-04,
8.685183e-05, 1.546110e-04, 9.204908e-04, 3.439569e-03, 6.646307e-03, 7.001711e-03, 4.076310e-03, 8.055459e-04, 6.350488e-10, 2.312147e-06,
1.584547e-03, 1.315706e-02, 4.601747e-02,           NA)

这是我的回报:

 c(-0.935414347, -0.908840790, -0.882955147, -0.857722698, -0.833111287, -0.809091076, -0.785634328, -0.762715212, -0.740309633, -0.718395083,
-0.696950500, -0.675956149, -0.655393513, -0.635245193, -0.615494824, -0.596126988, -0.577127150, -0.558481585, -0.540177322, -0.522202092,
-0.504544274, -0.487192852, -0.470137374, -0.453367914, -0.436875037, -0.420649768, -0.404683560, -0.388968270, -0.373496135, -0.358259744,
-0.343252021, -0.328466203, -0.313895825, -0.299534697, -0.285376894, -0.271416740, -0.257648791, -0.244067828, -0.230668838, -0.217447010,
-0.204397720, -0.191516523, -0.178799144, -0.166241467, -0.153839531, -0.141589522, -0.129487761, -0.117530703, -0.105714928, -0.094037138,
-0.082494145, -0.071082874, -0.059800353, -0.048643708, -0.037610161, -0.026697027, -0.015901704, -0.005221677,  0.005345492,  0.015802162,
0.026150621,  0.036393085,  0.046531703,  0.056568562,  0.066505681,  0.076345025,  0.086088499,  0.095737954,  0.105295185,  0.114761940,
0.124139915,  0.133430760,  0.142636079,  0.151757433,  0.160796339,  0.169754274,  0.178632677,  0.187432947,  0.196156448,  0.204804506,
0.213378417,  0.221879440,  0.230308804,  0.238667708,  0.246957319,  0.255178777,  0.263333194,  0.271421653,  0.279445214,  0.287404910,
0.295301748,  0.303136715,  0.310910773,  0.318624860,  0.326279895,  0.333876775,  0.341416378,  0.348899561,  0.356327161,  0.363699998,
0.371018874,  0.378284573,  0.385497862,  0.392659493,  0.399770198,  0.406830699,  0.413841698,  0.420803885,  0.427717934,  0.434584508,
0.441404253,  0.448177805,  0.454905784,  0.461588799,  0.468227448,  0.474822316,  0.481373976,  0.487882992,  0.494349914,  0.500775283,
0.507159631,  0.513503477,  0.519807332,  0.526071697,  0.532297065,  0.538483916,  0.544632726,  0.550743959,  0.556818072,  0.562855512,
0.568856721,  0.574822129,  0.580752162,  0.586647238,  0.592507765,  0.598334146,  0.604126777,  0.609886046,  0.615612336,  0.621306023, 0.626967475,  0.632597055,  0.638195120,  0.643762022,  0.649298104,  0.654803707,  0.660279164,  0.665724804,  0.671140949,  0.676527917,
0.681886022,  0.687215570,  0.692516865,  0.697790204,  0.703035881,  0.708254184,  0.713445397,  0.718609802,  0.723747672,  0.728859279,
0.733944890,  0.739004769,  0.744039175,  0.749048362,  0.754032582,  0.758992083,  0.763927108,  0.768837899,  0.773724691,  0.778587719,
0.783427212,  0.788243398,  0.793036498,  0.797806735,  0.802554324,  0.807279480,  0.811982414,  0.816663334,  0.821322445,  0.825959950,
0.830576047,  0.835170933,  0.839744804,  0.844297849,  0.848830257,  0.853342216,  0.857833908,  0.862305516,  0.866757217,  0.871189188, 0.875601603, 0.879994635,  0.884368452,  0.888723222,  0.893059110,  0.897376280,  0.901674891,  0.905955104,  0.910217074,  0.914460957,  0.918686906,  0.922895071,  0.927085602,  0.931258645,  0.935414347)

回报长于密度,因为我除以上面的差异。

0 个答案:

没有答案