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:

    Man always made, and still makes, grotesque blunders in selecting and measuring forces, taken at random from the heap, but he never made a mistake in the value he set on the whole, which he symbolized as unity and worshipped as God. To this day, his attitude towards it has never changed, though science can no longer give to force a name.
    Henry Brooks Adams (1838–1918)

    The man who pretends that the distribution of income in this country reflects the distribution of ability or character is an ignoramus. The man who says that it could by any possible political device be made to do so is an unpractical visionary. But the man who says that it ought to do so is something worse than an ignoramous and more disastrous than a visionary: he is, in the profoundest Scriptural sense of the word, a fool.
    George Bernard Shaw (1856–1950)