org.jscience.mathematics.statistics
Class WalkPositionDistribution

java.lang.Object
  extended by org.jscience.mathematics.statistics.Distribution
      extended by org.jscience.mathematics.statistics.WalkPositionDistribution
All Implemented Interfaces:
java.io.Serializable

public class WalkPositionDistribution
extends Distribution
implements java.io.Serializable

This class models the distribution of the position at time n for a random walk on the interval [0, n].

See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.jscience.mathematics.statistics.Distribution
CONTINUOUS, DISCRETE, MIXED
 
Constructor Summary
WalkPositionDistribution()
          This default constructor creates a new WalkPositionDistribution with time parameter 10 and probability p = 0.5.
WalkPositionDistribution(int n, double p)
          This general constructor creates a new distribution with specified time and probability parameters.
 
Method Summary
 double getDensity(double x)
          This method computes the density function.
 double getMaxDensity()
          This method returns the maximum value of the density function.
 double getMean()
          This method computes the mean.
 double getProbability()
          This method returns the probability parameter.
 double getSteps()
          This method returns the number of steps in the random walk.
 double getVariance()
          This method computes the variance.
 void setParameters(int n, double p)
          This method sets the time and probability parameters.
 void setProbability(double p)
          This method sets the probability parameter.
 void setSteps(int n)
          This method sets the number of steps.
 double simulate()
          This method simulates a value from the distribution.
 java.lang.String toString()
          This method returns a string that gives the name of the distribution and the values of the parameters.
 
Methods inherited from class org.jscience.mathematics.statistics.Distribution
getCDF, getDomain, getFailureRate, getMedian, getMGF, getMoment, getMoment, getPGF, getQuantile, getSD, getType, setDomain, setDomain
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

WalkPositionDistribution

public WalkPositionDistribution(int n,
                                double p)
This general constructor creates a new distribution with specified time and probability parameters.

Parameters:
n - the number of steps
p - the probabiltiy of a step in the positive direction

WalkPositionDistribution

public WalkPositionDistribution()
This default constructor creates a new WalkPositionDistribution with time parameter 10 and probability p = 0.5.

Method Detail

setParameters

public void setParameters(int n,
                          double p)
This method sets the time and probability parameters.

Parameters:
n - the number of steps
p - the probability of a step in the positive direction

getDensity

public double getDensity(double x)
This method computes the density function.

Specified by:
getDensity in class Distribution
Parameters:
x - a number in the domain of the distribution
Returns:
the probability density at x

getMaxDensity

public double getMaxDensity()
This method returns the maximum value of the density function.

Overrides:
getMaxDensity in class Distribution
Returns:
the maximum value of the probability density function

getMean

public double getMean()
This method computes the mean.

Overrides:
getMean in class Distribution
Returns:
the mean of the distribution

getVariance

public double getVariance()
This method computes the variance.

Overrides:
getVariance in class Distribution
Returns:
the variance of the distribution

setSteps

public void setSteps(int n)
This method sets the number of steps.

Parameters:
n - the number of steps

getSteps

public double getSteps()
This method returns the number of steps in the random walk.

Returns:
the number of steps

setProbability

public void setProbability(double p)
This method sets the probability parameter.

Parameters:
p - the probability of a step in the positve direciton

getProbability

public double getProbability()
This method returns the probability parameter.

Returns:
the probability of a step in the positive direction.

simulate

public double simulate()
This method simulates a value from the distribution.

Overrides:
simulate in class Distribution
Returns:
a simulated value from the distribution

toString

public java.lang.String toString()
This method returns a string that gives the name of the distribution and the values of the parameters.

Overrides:
toString in class Distribution
Returns:
a string giving the name of the distribution and the values of the parameters