Nengo.ca

ca.nengo.math.impl
Class GaussianPDF

java.lang.Object
  extended by ca.nengo.math.impl.GaussianPDF
All Implemented Interfaces:
Function, PDF, java.io.Serializable, java.lang.Cloneable

public class GaussianPDF
extends java.lang.Object
implements PDF

Univariate Gaussian probability density function.

See Also:
Serialized Form

Constructor Summary
GaussianPDF()
          Instantiates with default mean=0 and variance=1
GaussianPDF(float mean, float variance)
           
GaussianPDF(float mean, float variance, float peak)
          Constructs a scaled Gaussian with the given peak value.
 
Method Summary
 PDF clone()
           
static float[] doSample()
          This method is publically exposed because normal deviates are often needed, and static access allows the compiler to inline the call, which brings a small performance advantage.
 int getDimension()
           
 float getMean()
           
 float getPeak()
           
 boolean getScalePeakWithVariance()
           
 float getVariance()
           
 float map(float[] from)
           
 float[] multiMap(float[][] from)
           
 float[] sample()
           
 void setMean(float mean)
           
 void setPeak(float peak)
           
 void setScalePeakWithVariance(boolean scale)
           
 void setVariance(float variance)
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GaussianPDF

public GaussianPDF(float mean,
                   float variance)
Parameters:
mean - Mean of the distribution
variance - Variance of the distribution

GaussianPDF

public GaussianPDF(float mean,
                   float variance,
                   float peak)
Constructs a scaled Gaussian with the given peak value.

Parameters:
mean - Mean of the distribution
variance - Variance of the distribution
peak - Maximum value of scaled Gaussian

GaussianPDF

public GaussianPDF()
Instantiates with default mean=0 and variance=1

Method Detail

setMean

public void setMean(float mean)
Parameters:
mean - Mean of the distribution

getMean

public float getMean()
Returns:
Mean of the distribution

setVariance

public void setVariance(float variance)
Parameters:
variance - Variance of the distribution

getVariance

public float getVariance()
Returns:
Variance of the distribution

setPeak

public void setPeak(float peak)
Parameters:
peak - Maximum value of scaled Gaussian

getPeak

public float getPeak()
Returns:
Maximum value of scaled Gaussian

setScalePeakWithVariance

public void setScalePeakWithVariance(boolean scale)
Parameters:
scale - If true, the peak of the distribution scales automatically so that the integral is 1

getScalePeakWithVariance

public boolean getScalePeakWithVariance()
Returns:
If true, the peak of the distribution scales automatically so that the integral is 1

sample

public float[] sample()
Specified by:
sample in interface PDF
Returns:
A random sample from this density
See Also:
PDF.sample()

doSample

public static float[] doSample()
This method is publically exposed because normal deviates are often needed, and static access allows the compiler to inline the call, which brings a small performance advantage.

Returns:
Two random samples from a normal distribution (mean 0; variance 1)

getDimension

public int getDimension()
Specified by:
getDimension in interface Function
Returns:
1
See Also:
Function.getDimension()

map

public float map(float[] from)
Specified by:
map in interface Function
Parameters:
from - Must have same length as getDimension()
Returns:
result of function operation on arg
See Also:
Function.map(float[])

multiMap

public float[] multiMap(float[][] from)
Specified by:
multiMap in interface Function
Parameters:
from - An array of arguments; each element must have length getDimension().
Returns:
Array of results of function operation on each arg
See Also:
Function.multiMap(float[][])

clone

public PDF clone()
          throws java.lang.CloneNotSupportedException
Specified by:
clone in interface Function
Specified by:
clone in interface PDF
Overrides:
clone in class java.lang.Object
Returns:
Valid clone
Throws:
java.lang.CloneNotSupportedException - if clone can't be made

Nengo.ca