Inverse of the incomplete (regularized) beta integral.

You're viewing an older version of this page (#496). View the current version.

View versions (2)

Interface

GPL Licence — free for non commercial use. See Licence details.

FUNCTION

fdx

Interactive Calculator

dx1
x
a
b
Result

FUNCTION

beta_reg_inv_series

Interactive Calculator

y
a
b
logBeta
Result

FUNCTION

beta_reg_inv

Computes the inverse of incomplete beta integral, I_y^{-1}(a,b) such that if

y=I_x(a,b)
(1)

then

x=I_y^{-1}(a,b)
(2)

Alternatively, given y the function finds x such that

beta_reg(x, a, b, upper) = y

An 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&params=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&params=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.831951

Therefore you would only expect to loose you entire crop about once every ninty years (=1/0.011349) And annually you should expect to loos ~&pound;3.83.

Parameters

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
Author

Alex Karakulov and Will Bateman

Interactive Calculator

y
a
b
upper
eps
Result

FUNCTION

beta_reg_inv_series

An approximation of the inverse generalized Beta CDF.

When a>b and a>0,b>0

I^{-1}_y(a,b) = (a y \Beta(a,b))^{1/a} + \frac{b-1}{a+1} (a y \Beta(a,b))^{2/a} + \frac{(b-1)(a^2+3ba -a+5b-4)}{2(a+1)^2(a+2)} (a y \Beta(a,b))^{3/a}
(3)

Parameters

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.

Interactive Calculator

y
a
b
logBeta
Result