ca.nengo.math
Class PDFTools

java.lang.Object
  extended by ca.nengo.math.PDFTools

public class PDFTools
extends java.lang.Object

Convenience methods for using PDFs.

Author:
Bryan Tripp

Constructor Summary
PDFTools()
           
 
Method Summary
static double random()
          Use this rather than Math.random(), to allow user to reproduce random results by setting the seed.
static boolean sampleBoolean(PDF pdf)
          Note: PDF treated as univariate (only first dimension considered).
static float sampleFloat(PDF pdf)
          Note: PDF treated as univariate (only first dimension considered).
static int sampleInt(PDF pdf)
          Note: PDF treated as univariate (only first dimension considered).
static void setSeed(long seed)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PDFTools

public PDFTools()
Method Detail

sampleInt

public static int sampleInt(PDF pdf)
Note: PDF treated as univariate (only first dimension considered).

Parameters:
pdf - The PDF from which to sample
Returns:
Sample from PDF rounded to nearest integer

sampleBoolean

public static boolean sampleBoolean(PDF pdf)
Note: PDF treated as univariate (only first dimension considered).

Parameters:
pdf - The PDF from which to sample
Returns:
True iff sample from PDF is > 1

sampleFloat

public static float sampleFloat(PDF pdf)
Note: PDF treated as univariate (only first dimension considered).

Parameters:
pdf - The PDF from which to sample
Returns:
Sample from PDF (this is a convenience method for getting 1st dimension of sample() result)

random

public static double random()
Use this rather than Math.random(), to allow user to reproduce random results by setting the seed.

Returns:
A random sample between 0 and 1

setSeed

public static void setSeed(long seed)
Parameters:
seed - New random seed for random()