Inverse Gaussian Distribution - Generating Random Variates From An Inverse-Gaussian Distribution

Generating Random Variates From An Inverse-Gaussian Distribution

The following algorithm may be used.

Generate a random variate from a normal distribution with a mean of 0 and 1 standard deviation


\displaystyle \nu = N(0,1).

Square the value


\displaystyle y = \nu^2

and use this relation


x = \mu + \frac{\mu^2 y}{2\lambda} - \frac{\mu}{2\lambda}\sqrt{4\mu \lambda y + \mu^2 y^2}.

Generate another random variate, this time sampled from a uniformed distribution between 0 and 1


\displaystyle z = U(0,1).

If


z \le \frac{\mu}{\mu+x}

then return


\displaystyle
x

else return


\frac{\mu^2}{x}.

Sample code in Java:

public double inverseGaussian(double mu, double lambda) { Random rand = new Random; double v = rand.nextGaussian; // sample from a normal distribution with a mean of 0 and 1 standard deviation double y = v*v; double x = mu + (mu*mu*y)/(2*lambda) - (mu/(2*lambda)) * Math.sqrt(4*mu*lambda*y + mu*mu*y*y); double test = rand.nextDouble; // sample from a uniform distribution between 0 and 1 if (test <= (mu)/(mu + x)) return x; else return (mu*mu)/x; }

Read more about this topic:  Inverse Gaussian Distribution

Famous quotes containing the words random and/or distribution:

    ... the random talk of people who have no chance of immortality and thus can speak their minds out has a setting, often, of lights, streets, houses, human beings, beautiful or grotesque, which will weave itself into the moment for ever.
    Virginia Woolf (1882–1941)

    The question for the country now is how to secure a more equal distribution of property among the people. There can be no republican institutions with vast masses of property permanently in a few hands, and large masses of voters without property.... Let no man get by inheritance, or by will, more than will produce at four per cent interest an income ... of fifteen thousand dollars] per year, or an estate of five hundred thousand dollars.
    Rutherford Birchard Hayes (1822–1893)