Skip to main content

Generating generalized inverse Gaussian random variates


The generalized inverse Gaussian distribution has become quite popular in financial engineering. The most popular random variate generator is due to Dagpunar (Commun. Stat., Simul. Comput. 18:703–710, 1989). It is an acceptance-rejection algorithm method based on the Ratio-of-Uniforms method. However, it is not uniformly fast as it has a prohibitive large rejection constant when the distribution is close to the gamma distribution. Recently some papers have discussed universal methods that are suitable for this distribution. However, these methods require an expensive setup and are therefore not suitable for the varying parameter case which occurs in, e.g., Gibbs sampling. In this paper we analyze the performance of Dagpunar’s algorithm and combine it with a new rejection method which ensures a uniformly fast generator. As its setup is rather short it is in particular suitable for the varying parameter case.

This is a preview of subscription content, access via your institution.

Fig. 1
Fig. 2
Fig. 3
Algorithm 1
Algorithm 2
Algorithm 3
Fig. 4


  1. Eberlein, E., Keller, U.: Hyperbolic distributions in finance. Bernoulli 1, 281–299 (1995)

    Article  MATH  Google Scholar 

  2. Seshadri, V.: The Inverse Gaussian Distribution. Lecture Notes in Statistics, vol. 137. Springer, New York (1999)

    MATH  Google Scholar 

  3. Barndorff-Nielsen, O., Blæsild, P., Halgreen, C.: First hitting time models for the generalized inverse Gaussian distribution. Stoch. Process. Appl. 7(1), 49–54 (1978). doi:10.1016/0304-4149(78)90036-4

    Article  MATH  Google Scholar 

  4. Jørgensen, B.: Statistical Properties of the Generalized Inverse Gaussian Distribution. Lecture Notes in Statistics, vol. 9. Springer, New York (1982)

    Google Scholar 

  5. Johnson, N., Kotz, S., Balakrishnan, N.: Continuous Univariate Distributions vol. 1, 2nd edn. Wiley, New York (1994)

    MATH  Google Scholar 

  6. Abramowitz, M., Stegun, I.A. (eds.): Handbook of Mathematical Functions 9th edn. Dover, New York (1972). ISBN 0486-612-724

    MATH  Google Scholar 

  7. Dagpunar, J.S.: An easily implemented generalised inverse Gaussian generator. Commun. Stat., Simul. Comput. 18, 703–710 (1989)

    Article  MathSciNet  Google Scholar 

  8. Lehner, K.: Erzeugung von Zufallszahlen aus zwei exotischen Verteilungen, Diploma Thesis, Tech. Univ. Graz, Austria, 107 pp. (1989)

  9. Atkinson, A.C.: The simulation of generalized inverse Gaussian and hyperbolic random variables. SIAM J. Sci. Stat. Comput. 3, 502–515 (1982)

    Article  MATH  Google Scholar 

  10. Dagpunar, J.S.: Simulation and Monte Carlo with Applications in Finance and MCMC. Wiley, New York (2007)

    Book  MATH  Google Scholar 

  11. Leydold, J., Hörmann, W.: Generating generalized inverse Gaussian random variates by fast inversion. Comput. Stat. Data Anal. 55(1), 213–217 (2011). doi:10.1016/j.csda.2010.07.011

    Article  MATH  Google Scholar 

  12. Derflinger, G., Hörmann, W., Leydold, J.: Random variate generation by numerical inversion when only the density is known. ACM Trans. Model. Comput. Simul. 20(4), 1-25 (2010)

    Article  Google Scholar 

  13. Hörmann, W., Leydold, J., Derflinger, G.: Automatic Nonuniform Random Variate Generation. Springer, Berlin (2004)

    Book  MATH  Google Scholar 

  14. Ahrens, J.H.: A one-table method for sampling from continuous and discrete distributions. Computing 54(2), 127–146 (1995)

    Article  MATH  MathSciNet  Google Scholar 

  15. Kinderman, A.J., Monahan, J.F.: Computer generation of random variables using the ratio of uniform deviates. ACM Trans. Math. Softw. 3(3), 257–260 (1977)

    Article  MATH  Google Scholar 

  16. Leydold, J.: Automatic sampling with the Ratio-of-Uniforms method. ACM Trans. Math. Softw. 26(1), 78–98 (2000). doi:10.1145/347837.347863

    Article  MATH  Google Scholar 

  17. Hörmann, W.: A rejection technique for sampling from T-concave distributions. ACM Trans. Math. Softw. 21(2), 182–193 (1995)

    Article  MATH  Google Scholar 

  18. Devroye, L.: Non-Uniform Random Variate Generation. Springer, New York (1986)

    Book  MATH  Google Scholar 

  19. Devroye, L.: A simple algorithm for generating random variates with a log-concave density. Computing 33(3–4), 247–257 (1984)

    Article  MATH  MathSciNet  Google Scholar 

  20. Leydold, J.: A simple universal generator for continuous and discrete univariate T-concave distributions. ACM Trans. Math. Softw. 27(1), 66–82 (2001)

    Article  MATH  Google Scholar 

  21. Dagpunar, J.: In: Principles of Random Variate Generation. Clarendon, Oxford (1988)

    Google Scholar 

Download references


The authors gratefully acknowledge the useful suggestions of the area editor and two anonymous referees that helped to improve the presentation of the paper.

Author information



Corresponding author

Correspondence to Josef Leydold.



Proof of Lemma 11

Let λ∈[0,1) be fixed. Recall that . Notice that does not contain any point left of the line u=−mv since we have used μ=m in (3), i.e., we have shifted quasi-density g by the mode m to the left, see Fig. 5. Consequently, −mv +u and . Let x + defined as in Sect. 2, i.e., it is the unique root of (5) greater than m. Thus \((x-m)\sqrt{g(x)}\) is monotonically increasing in [m,x +].

Fig. 5

, , (−mv +,u+)×(0,v +), and (u 1,v 1) in proof of Lemma 11

Now choose x 1∈(0,x +m) and let (u 1,v 1) be the point on the boundary of corresponding to x 1, i.e., \(v_{1}=\sqrt{g(x_{1}+m)}\) and u 1=xv 1. Then does not intersect the open rectangle (u 1,u +)×(v 1,v +) and thus

We therefore find


Now let

$$x_0^+(\beta) = \frac{1}{\beta} \bigl((1+\lambda)+\sqrt{(1+ \lambda)^2+\beta^2} \bigr). $$

It is the unique maximum of \(x\sqrt{g(x)}\), see Sect. 5. Since \(((x-m)\sqrt{g(x)} )'\geq (x\sqrt{g(x)} )'\) for all xm, we find \(x_{0}^{+}\leq x^{+}\). Now define

$$u^*=\bigl(x_0^+-m\bigr)\sqrt{g\bigl(x_0^+ \bigr)}. $$

Clearly \(u^{*}\leq u^{+}=\sup (x-m)\sqrt{g(x)}\), and thus ε=u +u ≥0. From (10) we then obtain


Now set

We first have to check whether the condition x 1∈(0,x +m) is fulfilled. For the limits β→0 we find

An immediate consequence is that for sufficiently small β>0, \(x_{1}(\beta) < x_{0}^{+}(\beta)-m(\beta) \leq x^{+}(\beta)-m(\beta)\) which shows that x 1(β)∈(0,x +m) when β is close enough to zero. Thus inequality (11) holds. Moreover,

$$\lim_{\beta\to 0} u_1(\beta) = \lim_{\beta\to 0} v_1(\beta) \cdot \lim_{\beta\to 0} x_1( \beta) = 1. $$

For the denominators in (11) we find


Collecting all limits we find that all fractions on the right hand side of inequality (11) converge to 0 and thus as claimed.

Rights and permissions

Reprints and Permissions

About this article

Cite this article

Hörmann, W., Leydold, J. Generating generalized inverse Gaussian random variates. Stat Comput 24, 547–557 (2014).

Download citation


  • Random variate generation
  • Generalized inverse Gaussian distribution
  • Varying parameters