## org.apache.mahout.clustering.dirichlet
Class UncommonDistributions

    java.lang.Object
      org.apache.mahout.clustering.dirichlet.UncommonDistributions

    public final class UncommonDistributions

extends java.lang.Object

Method Summary
`static double` `dNorm(double x, double m, double s)` Return the normal density function value for the sample x pdf = 1/[sqrt(2*p)*s] * e^{-1/2*[(x-m)/s]^2}
`static double` `rBeta(double shape1, double shape2)` Returns a random sample from a beta distribution with the given shapes
`static Vector` `rBeta(int K, double shape1, double shape2)` Returns a vector of random samples from a beta distribution with the given shapes
`static int` `rBinomial(int n, double p)` Returns an integer sampled according to this distribution.
`static double` `rChisq(double df)` Return a random sample from the chi-squared (chi^2) distribution with df degrees of freedom.
`static Vector` `rDirichlet(Vector totalCounts, double alpha0)` Sample from a Dirichlet distribution, returning a vector of probabilities using a stick-breaking algorithm
`static double` `rGamma(double k, double lambda)` Returns a double sampled according to this distribution.
`static Vector` `rMultinom(int size, Vector probabilities)` Returns a multinomial vector sampled from the given probabilities rmultinom should be implemented as successive binomial sampling.
`static int` `rMultinom(Vector probabilities)` Returns one sample from a multinomial.
`static double` `rNorm(double mean, double sd)` Return a random value from a normal distribution with the given mean and standard deviation

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Method Detail

### rGamma

    public static double rGamma(double k,
                                double lambda)

  Returns a double sampled according to this distribution. Uniformly fast for all k > 0. (Reference: Non-Uniform Random Variate Generation, Devroye http://cgm.cs.mcgill.ca/~luc/rnbookindex.html) Uses Cheng's rejection algorithm (GB) for k>=1, rejection from Weibull distribution for 0 < k < 1.

### rBeta

    public static double rBeta(double shape1,
                               double shape2)

  Returns a random sample from a beta distribution with the given shapes

  Parameters:
    `shape1` - a double representing shape1
    `shape2` - a double representing shape2
  Returns:
    a Vector of samples

### rBeta

    public static Vector rBeta(int K,
                               double shape1,
                               double shape2)

  Returns a vector of random samples from a beta distribution with the given shapes

  Parameters:
    `K` - the number of samples to return
    `shape1` - a double representing shape1
    `shape2` - a double representing shape2
  Returns:
    a Vector of samples

### rChisq

    public static double rChisq(double df)

  Return a random sample from the chi-squared (chi^2) distribution with df degrees of freedom.

  Returns:
    a double sample

### rNorm

    public static double rNorm(double mean,
                               double sd)

  Return a random value from a normal distribution with the given mean and standard deviation

  Parameters:
    `mean` - a double mean value
    `sd` - a double standard deviation
  Returns:
    a double sample

### dNorm

    public static double dNorm(double x,
                               double m,
                               double s)

  Return the normal density function value for the sample x pdf = 1/[sqrt(2*p)*s] * e^{-1/2*[(x-m)/s]^2}

  Parameters:
    `x` - a double sample value
    `m` - a double mean value
    `s` - a double standard deviation
  Returns:
    a double probability value

### rMultinom

    public static int rMultinom(Vector probabilities)

  Returns one sample from a multinomial.

### rMultinom

    public static Vector rMultinom(int size,
                                   Vector probabilities)

  Returns a multinomial vector sampled from the given probabilities rmultinom should be implemented as successive binomial sampling. Keep a normalizing amount that starts with 1 (I call it total). For each i k[i] = rbinom(p[i] / total, size); total -= p[i]; size -= k[i];

  Parameters:
    `size` - the size parameter of the binomial distribution
    `probabilities` - a Vector of probabilities
  Returns:
    a multinomial distribution Vector

### rBinomial

    public static int rBinomial(int n,
                                double p)

  Returns an integer sampled according to this distribution. Takes time proprotional to np + 1. (Reference: Non-Uniform Random Variate Generation, Devroye http://cgm.cs.mcgill.ca/~luc/rnbookindex.html) Second time-waiting algorithm.

### rDirichlet

    public static Vector rDirichlet(Vector totalCounts,
                                    double alpha0)

  Sample from a Dirichlet distribution, returning a vector of probabilities using a stick-breaking algorithm

  Parameters:
    `totalCounts` - an unnormalized count Vector
    `alpha0` - a double
  Returns:
    a Vector of probabilities

Copyright © 2008-2010 The Apache Software Foundation. All Rights Reserved.