I have forgotten
my Password

Or login with:

  • Facebookhttp://facebook.com/
  • Googlehttps://www.google.com/accounts/o8/id
  • Yahoohttps://me.yahoo.com
COST (GBP)
this unit 5.00
sub units 18.60
+
0
MathsSpecialGamma

beta reg inv

Inverse of the incomplete (regularized) beta integral.
Controller: CodeCogs

Dependents

Info

Interface

C++

Beta Reg Inv

 
doublebeta_reg_invdoubley
doublea
doubleb
boolupper = false
doubleeps = 1e-10 )
Computes the inverse of incomplete beta integral, \inline  I_y^{-1}(a,b) such that if then

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:
There is an error with your graph parameters for beta_reg_inv with options y=0:1 a=3 b=2:7:3 .size=medium

Error Message:Function beta_reg_inv failed. Ensure that: Invalid C++

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 Maths/Special/Gamma/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. Potatoes. While the carrots are more resilliant, i.e. 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 ~£3.83.

Parameters

ya percentile in the range 0<=y<=1
afirst shape paramter, a>0
bsecond shape parameter, b>0
upperif true probabilites are P[X<=x], otherwise P[X>x]. Default value = false
epsLevel of accuracy. Default value=1e-10

Authors

Alex Karakulov and Will Bateman
Source Code

Source code is available when you buy a Commercial licence.

Not a member, then Register with CodeCogs. Already a Member, then Login.


Beta Reg Inv Series

 
doublebeta_reg_inv_seriesdoubley
doublea
doubleb
doublelogBeta )[inline]
An approximation of the inverse generalized Beta CDF.

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

Parameters

ya percentile in the range 0<=y<=1
afirst shape paramter, a>0
bsecond shape parameter, b>0
logBetafor performance we also compute the complete log Beta(a,b) and pass in, see logBeta.
Source Code

Source code is available when you buy a Commercial licence.

Not a member, then Register with CodeCogs. Already a Member, then Login.