SuanShu, a Java numerical and statistical library

com.numericalmethod.suanshu.stats.random.multivariate
Class Multinomial

java.lang.Object
  extended by com.numericalmethod.suanshu.stats.random.multivariate.Multinomial
All Implemented Interfaces:
RandomVectorGenerator

public class Multinomial
extends java.lang.Object
implements RandomVectorGenerator

This class generate random vectors from a multinomial distribution.

The R equivalent function is rmultinom in package normix.


Constructor Summary
Multinomial(int size, double[] prob)
          Construct a Multinomial random vector generator.
Multinomial(int size, double[] prob, RandomNumberGenerator rng)
          Construct a Multinomial random vector generator.
 
Method Summary
 double[] nextVector()
          Get the next random vector.
 void seed(long... seeds)
          Seed the random number generator to produce repeatable sequences.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Multinomial

public Multinomial(int size,
                   double[] prob,
                   RandomNumberGenerator rng)
Construct a Multinomial random vector generator.

Parameters:
size - integer, say N, specifying the total number of objects that are put into K boxes in the typical multinomial experiment
prob - numeric non-negative vector of length K, specifying the probability for the K classes; is internally normalized to sum 1
rng - a uniform random number generator

Multinomial

public Multinomial(int size,
                   double[] prob)
Construct a Multinomial random vector generator.

Parameters:
size - integer, say N, specifying the total number of objects that are put into K boxes in the typical multinomial experiment
prob - numeric non-negative vector of length K, specifying the probability for the K classes; is internally normalized to sum 1
Method Detail

seed

public void seed(long... seeds)
Description copied from interface: RandomVectorGenerator
Seed the random number generator to produce repeatable sequences.

Specified by:
seed in interface RandomVectorGenerator
Parameters:
seeds - the seeds

nextVector

public double[] nextVector()
Description copied from interface: RandomVectorGenerator
Get the next random vector.

Specified by:
nextVector in interface RandomVectorGenerator
Returns:
the next random vector

SuanShu, a Java numerical and statistical library

Copyright © 2011 Numerical Method Inc. Ltd. All Rights Reserved.