<html>

  <head>
    <title>
      ASA266 - Estimating the Parameters of a Dirichlet PDF
    </title>
  </head>

  <body bgcolor="#EEEEEE" link="#CC0000" alink="#FF3300" vlink="#000055">

    <h1 align = "center">
      ASA266 <br> Estimating the Parameters of a Dirichlet PDF
    </h1>

    <hr>

    <p>
      <b>ASA266</b>
      is a FORTRAN77 library which
      estimates the parameters of a Dirichlet probability density function.
    </p>

    <p>
      <b>ASA266</b> is Applied Statistics Algorithm 266.  Source code for many
      Applied Statistics Algorithms is available through
      <a href = "http://lib.stat.cmu.edu/apstat">STATLIB</a>.
    </p>

    <p>
      The assumption is that a given process is governed by a Dirichlet
      distribution with parameters ALPHA(I), I = 1 to N, positive quantities
      which are required to sum to 1.  Each observation of the process yields
      a vector of N data values.  After a number of observations of this sort,
      it is desired to estimate the the underlying parameters ALPHA of
      the Dirichlet distribution.
    </p>

    <p>
      There are a considerable number of routines required to get DIRICH
      to work.  In some cases, there are several versions of the routines,
      and they all were included, in order to provide a way to check
      results.  Most of the routines are themselves Applied Statistics
      Algorithms, and their source code is available through
      <a href = "http://lib.stat.cmu.edu/apstat">STATLIB</a>.
    </p>

    <p>
      Also included is a routine DIRICHLET_SAMPLE, with which experiments
      can be carried out.  Values for the parameters ALPHA can be chosen,
      and data generated by DIRICHLET_SAMPLE.  Then DIRICH can analyze this
      data and attempt to determine the values of ALPHA.
    </p>

    <p>
      Another routine, DIRICHLET_MIX_SAMPLE, allows you to sample a
      probability distribution that is a weighted mixture of Dirichlet
      distributions.
    </p>

    <h3 align = "center">
      Languages:
    </h3>

    <p>
      <b>ASA266</b> is available in
      <a href = "../../f77_src/asa266/asa266.html">a FORTRAN77 version</a> and
      <a href = "../../f_src/asa266/asa266.html">a FORTRAN90 version</a> and
      <a href = "../../m_src/asa266/asa266.html">a MATLAB version.</a>
    </p>

    <h3 align = "center">
      Related Data and Programs:
    </h3>

    <p>
      <a href = "../../f77_src/asa032/asa032.html">
      ASA032</a>,
      a FORTRAN77 library which
      evaluates the incomplete Gamma integral.
    </p>

    <p>
      <a href = "../../f77_src/asa066/asa066.html">
      ASA066</a>,
      a FORTRAN77 library which
      evaluates the percentage points of the normal distribution.
    </p>

    <p>
      <a href = "../../f77_src/asa091/asa091.html">
      ASA091</a>,
      a FORTRAN77 library which
      evaluates the percentage points of the Chi-Squared distribution.
    </p>

    <p>
      <a href = "../../f77_src/asa103/asa103.html">
      ASA103</a>,
      a FORTRAN77 library
      which evaluates the digamma or psi function.
    </p>

    <p>
      <a href = "../../f77_src/asa111/asa111.html">
      ASA111</a>,
      a FORTRAN77 library
      which evaluates the percentage points of the normal distribution.
    </p>

    <p>
      <a href = "../../f77_src/asa121/asa121.html">
      ASA121</a>,
      a FORTRAN77 library
      which evaluates the trigamma function.
    </p>

    <p>
      <a href = "../../f77_src/asa147/asa147.html">
      ASA147</a>,
      a FORTRAN77 library
      which evaluates the incomplete Gamma function.
    </p>

    <p>
      <a href = "../../f77_src/asa239/asa239.html">
      ASA239</a>,
      a FORTRAN77 library
      which evaluates the percentage points of the Chi-Squared distribution
      and the incomplete Gamma function.
    </p>

    <p>
      <a href = "../../f_src/asa241/asa241.html">
      ASA241</a>,
      a FORTRAN90 library
      which evaluates the percentage points of the normal distribution.
    </p>

    <p>
      <a href = "../../f77_src/asa245/asa245.html">
      ASA245</a>,
      a FORTRAN77 library
      which evaluates the logarithm of the Gamma function.
    </p>

    <p>
      <a href = "../../f_src/dcdflib/dcdflib.html">
      DCDFLIB</a>,
      a FORTRAN90 library which
      evaluates and inverts
      a number of statistical distributions.
    </p>

    <p>
      <a href = "../../cpp_src/gsl/gsl.html">
      GSL</a>,
      a C++ library which
      includes many routines for evaluating
      probability distributions.
    </p>

    <p>
      <a href = "../../f77_src/normal/normal.html">
      NORMAL</a>,
      a FORTRAN77 library which
      samples the normal distribution.
    </p>

    <p>
      <a href = "../../f_src/prob/prob.html">
      PROB</a>,
      a FORTRAN90 library which
      evaluates the PDF, CDF, mean and variance for a number of probability
      density functions.
    </p>

    <p>
      <a href = "../../f77_src/test_values/test_values.html">
      TEST_VALUES</a>,
      a FORTRAN77 library which
      contains sample values
      for a number of distributions.
    </p>

    <p>
      <a href = "../../f77_src/toms291/toms291.html">
      TOMS291</a>,
      a FORTRAN77 library
      which evaluates the logarithm of the Gamma function.
    </p>

    <p>
      <a href = "../../f77_src/uniform/uniform.html">
      UNIFORM</a>,
      a FORTRAN77 library which
      samples the uniform distribution.
    </p>

    <h3 align = "center">
      Reference:
    </h3>

    <p>
      <ol>
        <li>
          AG Adams,<br>
          Algorithm 39:
          Areas Under the Normal Curve,<br>
          Computer Journal,<br>
          Volume 12, Number 2, May 1969, pages 197-198.
        </li>
        <li>
          Joachim Ahrens, Ulrich Dieter,<br>
          Computer Methods for Sampling from Gamma, Beta, Poisson and
          Binomial Distributions,<br>
          Computing,<br>
          Volume 12, Number 3, September 1974, pages 223-246.
        </li>
        <li>
          Joachim Ahrens, Ulrich Dieter,<br>
          Generating Gamma Variates by a Modified Rejection Technique,<br>
          Communications of the ACM,<br>
          Volume 25, Number 1, January 1982, pages 47-54.
        </li>
        <li>
          Jerry Banks, editor,<br>
          Handbook of Simulation,<br>
          Wiley, 1998,<br>
          ISBN: 0471134031,<br>
          LC: T57.62.H37.
        </li>
        <li>
          JD Beasley, SG Springer,<br>
          Algorithm AS 111:
          The Percentage Points of the Normal Distribution,<br>
          Applied Statistics,<br>
          Volume 26, Number 1, 1977, pages 118-121.
        </li>
        <li>
          Jose Bernardo,<br>
          Algorithm AS 103:
          Psi ( Digamma ) Function,<br>
          Applied Statistics,<br>
          Volume 25, Number 3, 1976, pages 315-317.
        </li>
        <li>
          Donald Best, DE Roberts,<br>
          Algorithm AS 91:
          The Percentage Points of the Chi-Squared Distribution,<br>
          Applied Statistics,<br>
          Volume 24, Number 3, 1975, pages 385-390.
        </li>
        <li>
          G Bhattacharjee,<br>
          Algorithm AS 32:
          The Incomplete Gamma Integral,<br>
          Applied Statistics,<br>
          Volume 19, Number 3, 1970, pages 285-287.
        </li>
        <li>
          William Cody, Kenneth Hillstrom,<br>
          Chebyshev Approximations for the Natural Logarithm of the
          Gamma Function,<br>
          Mathematics of Computation,<br>
          Volume 21, Number 98, April 1967, pages 198-203.
        </li>
        <li>
          William Cody, Anthony Strecok, Henry Thacher,<br>
          Chebyshev Approximations for the Psi Function,<br>
          Mathematics of Computation,<br>
          Volume 27, Number 121, January 1973, pages 123-127.
        </li>
        <li>
          John Hart, Ward Cheney, Charles Lawson, Hans Maehly,
          Charles Mesztenyi, John Rice, Henry Thacher,
          Christoph Witzgall,<br>
          Computer Approximations,<br>
          Wiley, 1968,<br>
          LC: QA297.C64.
        </li>
        <li>
          David Hill,
          Algorithm AS 66:
          The Normal Integral,<br>
          Applied Statistics,<br>
          Volume 22, Number 3, 1973, pages 424-427.
        </li>
        <li>
          Cornelius Lanczos,<br>
          A precision approximation of the gamma function,<br>
          SIAM Journal on Numerical Analysis, B,<br>
          Volume 1, 1964, pages 86-96.
        </li>
        <li>
          Chi Leung Lau,<br>
          Algorithm AS 147:
          A Simple Series for the Incomplete Gamma Integral,<br>
          Applied Statistics,<br>
          Volume 29, Number 1, 1980, pages 113-114.
        </li>
        <li>
          Allan Mcleod,<br>
          Algorithm AS 245:
          A Robust and Reliable Algorithm for the Logarithm
          of the Gamma Function,<br>
          Applied Statistics,<br>
          Volume 38, Number 2, 1989, pages 397-402.
        </li>
        <li>
          A. Naryanan,<br>
          Algorithm AS 266:
          Maximum Likelihood Estimation of the Parameters of the
          Dirichlet Distribution,<br>
          Applied Statistics,<br>
          Volume 40, Number 2, 1991, pages 365-374.
        </li>
        <li>
          Malcolm Pike, David Hill,<br>
          Algorithm 291:
          Logarithm of Gamma Function,<br>
          Communications of the ACM,<br>
          Volume 9, Number 9, September 1966, page 684.
        </li>
        <li>
          BE Schneider,<br>
          Algorithm AS 121:
          Trigamma Function,<br>
          Applied Statistics,<br>
          Volume 27, Number 1, 1978, pages 97-99.
        </li>
        <li>
          BL Shea,<br>
          Algorithm AS 239:
          Chi-squared and Incomplete Gamma Integral,<br>
          Applied Statistics,<br>
          Volume 37, Number 3, 1988, pages 466-473.
        </li>
        <li>
          Michael Wichura,<br>
          Algorithm AS 241:
          The Percentage Points of the Normal Distribution,<br>
          Applied Statistics,<br>
          Volume 37, Number 3, 1988, pages 477-484.
        </li>
      </ol>
    </p>

    <h3 align = "center">
      Source Code:
    </h3>

    <p>
      <ul>
        <li>
          <a href = "asa266.f90">asa266.f90</a>, the source code;
        </li>
        <li>
          <a href = "asa266.sh">asa266.sh</a>,
          commands to compile the source code;
        </li>
      </ul>
    </p>

    <h3 align = "center">
      Examples and Tests:
    </h3>

    <p>
      <ul>
        <li>
          <a href = "asa266_prb.f90">asa266_prb.f90</a>, the
          calling program;
        </li>
        <li>
          <a href = "asa266_prb.sh">asa266_prb.sh</a>,
          commands to compile, link and run the calling program;
        </li>
        <li>
          <a href = "asa266_prb_output.txt">asa266_prb_output.txt</a>, the sample
          output.
        </li>
      </ul>
    </p>

    <h3 align = "center">
      List of Routines:
    </h3>

    <p>
      <ul>
        <li>
          <b>ALNGAM</b> computes the logarithm of the Gamma function.
        </li>
        <li>
          <b>ALNORM</b> computes the cumulative density of the standard normal distribution.
        </li>
        <li>
          <b>ALOGAM</b> computes the logarithm of the Gamma function.
        </li>
        <li>
          <b>DIGAMMA</b> calculates the digamma or Psi function = d ( LOG ( GAMMA ( X ) ) ) / dX
        </li>
        <li>
          <b>DIRICHLET_CHECK</b> checks the parameters of the Dirichlet PDF.
        </li>
        <li>
          <b>DIRICHLET_ESTIMATE</b> estimates the parameters of a Dirichlet distribution.
        </li>
        <li>
          <b>DIRICHLET_MEAN</b> returns the means of the Dirichlet PDF.
        </li>
        <li>
          <b>DIRICHLET_MIX_MEAN</b> returns the means of a Dirichlet mixture PDF.
        </li>
        <li>
          <b>DIRICHLET_MIX_SAMPLE</b> samples a Dirichlet mixture PDF.
        </li>
        <li>
          <b>DIRICHLET_SAMPLE</b> samples the Dirichlet PDF.
        </li>
        <li>
          <b>DIRICHLET_VARIANCE</b> returns the variances of the Dirichlet PDF.
        </li>
        <li>
          <b>EXPONENTIAL_01_SAMPLE</b> samples the Exponential PDF with parameters 0, 1.
        </li>
        <li>
          <b>EXPONENTIAL_CDF_INV</b> inverts the Exponential CDF.
        </li>
        <li>
          <b>GAMAIN</b> computes the incomplete Gamma ratio.
        </li>
        <li>
          <b>GAMMA_LOG</b> calculates the natural logarithm of GAMMA ( X ) for positive X.
        </li>
        <li>
          <b>GAMMA_SAMPLE</b> samples the Gamma PDF.
        </li>
        <li>
          <b>GAMMAD</b> computes the Incomplete Gamma Integral
        </li>
        <li>
          <b>GAMMDS</b> computes the incomplete Gamma integral.
        </li>
        <li>
          <b>LNGAMMA</b> computes Log(Gamma(X)) using a Lanczos approximation.
        </li>
        <li>
          <b>NORMAL_01_SAMPLE</b> samples the standard Normal PDF.
        </li>
        <li>
          <b>NORMP</b> computes the cumulative density of the standard normal distribution.
        </li>
        <li>
          <b>NPROB</b> computes the cumulative density of the standard normal distribution.
        </li>
        <li>
          <b>PPCHI2</b> evaluates the percentage points of the chi-squared PDF.
        </li>
        <li>
          <b>PPND</b> produces the normal deviate value corresponding to lower tail area = P.
        </li>
        <li>
          <b>PPND16</b> produces the normal deviate value corresponding to lower tail area = P.
        </li>
        <li>
          <b>PPND7</b> produces the normal deviate value corresponding to lower tail area = P.
        </li>
        <li>
          <b>PSI</b> evaluates the psi or digamma function, d/dx ln(gamma(x)).
        </li>
        <li>
          <b>R4_RANDOM</b> returns a random real in a given range.
        </li>
        <li>
          <b>R4COL_MEAN</b> returns the means of columns of a real array.
        </li>
        <li>
          <b>R4COL_VARIANCE</b> returns the variances of the columns of a real array.
        </li>
        <li>
          <b>TIMESTAMP</b> prints the current YMDHMS date as a time stamp.
        </li>
        <li>
          <b>TRIGAMMA</b> calculates trigamma(x) = d**2 log(Gamma(x)) / dx**2.
        </li>
      </ul>
    </p>

    <p>
      You can go up one level to <a href = "../f_src.html">
      the FORTRAN90 source codes</a>.
    </p>

    <hr>

    <i>
      Last revised on 29 December 2007.
    </i>

    <!-- John Burkardt -->

  </body>

</html>
