Or login with:
| doublebeta_reg_inv( | double | y | |
| double | a | ||
| double | b | ||
| bool | upper = false | ||
| double | eps = 1e-10 | ) |
beta_reg(x, a, b, upper) = yAn illustration of the shape of this function is:
#include <codecogs/maths/special/gamma/beta_reg_inv.h> #include <codecogs/stats/random/mersenne.h> #include <codecogs/stats/moments/frequency.h> int main(int argc, char* argv[]) { Stats::Random::Mersenne UniformGen((int)time(0)/MERSENNEDIV); Stats::Moments::Frequency bins(20,0,7); for(int i=0;i<1000000;i++) { double percentile = UniformGen.genReal(); double val = 2.0*Maths::Special::Gamma::beta_reg_inv(percentile, 0.5, 1.5, false, 1e-10) + 5.0*Maths::Special::Gamma::beta_reg_inv(percentile, 4, 2, false, 1e-10); bins.add(val); } double sum=0; for(int i=0;i<22;i++) { printf("\n%d %lf %d %lf ",i, bins.get_x(i), bins.get_count(i), bins.get_freq(i)); sum+=bins.get_x(i)*bins.get_freq(i); } printf("\n Mean Annual loss=%lf",sum); }Output:
0 -0.175000 0 0.000000 1 0.175000 127 0.000127 2 0.525000 1589 0.001589 3 0.875000 6511 0.006511 4 1.225000 15616 0.015616 5 1.575000 29847 0.029847 6 1.925000 47600 0.047600 7 2.275000 66050 0.066050 8 2.625000 81293 0.081293 9 2.975000 90582 0.090582 10 3.325000 92933 0.092933 11 3.675000 91748 0.091748 12 4.025000 87134 0.087134 13 4.375000 79734 0.079734 14 4.725000 71898 0.071898 15 5.075000 63944 0.063944 16 5.425000 54870 0.054870 17 5.775000 45694 0.045694 18 6.125000 36053 0.036053 19 6.475000 25289 0.025289 20 6.825000 11488 0.011488 21 7.175000 0 0.000000 Mean Annual loss=3.831951Therefore you would only expect to loose you entire crop about once every ninty years (=1/0.011349) And annually you should expect to loos ~£3.83.
| y | a percentile in the range 0<=y<=1 |
| a | first shape paramter, a>0 |
| b | second shape parameter, b>0 |
| upper | if true probabilites are P[X<=x], otherwise P[X>x]. Default value = false |
| eps | Level of accuracy. Default value=1e-10 |
Source code is available when you buy a Commercial licence.
Not a member, then Register with CodeCogs. Already a Member, then Login.
| doublebeta_reg_inv_series( | double | y | |
| double | a | ||
| double | b | ||
| double | logBeta | )[inline] |
| y | a percentile in the range 0<=y<=1 |
| a | first shape paramter, a>0 |
| b | second shape parameter, b>0 |
| logBeta | for performance we also compute the complete log Beta(a,b) and pass in, see logBeta. |
Source code is available when you buy a Commercial licence.
Not a member, then Register with CodeCogs. Already a Member, then Login.
You must login to leave a messge