beta_reg_inv
Inverse of the incomplete (regularized) beta integral.
Interface
#include <codecogs/maths/special/gamma/beta_reg_inv.h>
using namespace Maths::Special::Gamma;
inline double fdx(double dx1, double x, double a, double b)inline double beta_reg_inv_series(double y, double a, double b, double logBeta);double beta_reg_inv(double y, double a, double b, bool upper=false, double eps=1e-10)inline double beta_reg_inv_series(double y, double a, double b, double logBeta)
FUNCTION
fdx
Interactive Calculator
Computing…
Set a range above first to export a graph.
FUNCTION
beta_reg_inv_series
Interactive Calculator
Computing…
Set a range above first to export a graph.
FUNCTION
beta_reg_inv
Computes the inverse of incomplete beta integral, such that if
then
Alternatively, given y the function finds x such that
beta_reg(x, a, b, upper) = yAn illustration of the shape of this function is: \graph y=0:1 a=3 b=2:7:3 .size=medium
The solution is computed using a good first initial prediction, followed by a number of corrections using a modified Newton solver, until the required accuracy is achieved. This method we believe to be the fastest known method, with good accuracy down to 1e-150.
See also beta_reg
Example 1
Imagine you have two types of events that cause a financial loss that are 100% correlated. For example, the damange due to some weather event (perhaps excess rain) has been shown to damage your crop of potatoes and carrots. Although the intensity of rain experienced by each plant type is 100% correlated (the plants are next door to each other), the damage that occurs fit different beta distributions. Lets say the potatoes are fairly sensative to rain, with a lot of loss occuring with a small amount of rain, i.e. /pages/calculator/graph.php?mod=180&fn=CDF_ddd¶ms=x,a,b&values=0:1,0.5,1.5 "Potatoes." While the carrots are more resilliant, i.e. /pages/calculator/graph.php?mod=180&fn=CDF_ddd¶ms=x,a,b&values=0:1,4,2 "Carrots." Next assume that if all your carrots are destroyed you lose £5, while all your potatoes would lose you £2 and that you have one extreme rain event a year. With the following code we can compute a histogram of likely losses over a million years.
#include <codecogs/maths/special/gamma/beta_reg_inv.h>
#include <codecogs/statistics/random/mersenne.h>
#include <codecogs/statistics/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.
Parameters
Alex Karakulov and Will Bateman
Interactive Calculator
Computing…
Set a range above first to export a graph.
FUNCTION
beta_reg_inv_series
An approximation of the inverse generalized Beta CDF.
When a>b and a>0,b>0
Parameters
Interactive Calculator
Computing…
Set a range above first to export a graph.