gov.sandia.cognition.statistics.distribution

## Class BernoulliDistribution

• ### Nested Class Summary

Nested Classes
Modifier and Type Class and Description
`static class ` `BernoulliDistribution.CDF`
CDF of a Bernoulli distribution.
`static class ` `BernoulliDistribution.PMF`
PMF of the Bernoulli distribution.
• ### Field Summary

Fields
Modifier and Type Field and Description
`static double` `DEFAULT_P`
Default Bernoulli parameter, 0.5
• ### Constructor Summary

Constructors
Constructor and Description
`BernoulliDistribution()`
Creates a new instance of BernoulliDistribution
`BernoulliDistribution(BernoulliDistribution other)`
Copy Constructor
`BernoulliDistribution(double p)`
Creates a new instance of BernoulliDistribution
• ### Method Summary

All Methods
Modifier and Type Method and Description
`void` `convertFromVector(Vector parameters)`
Converts the object from a Vector of parameters.
`Vector` `convertToVector()`
Converts the object to a vector.
`BernoulliDistribution.CDF` `getCDF()`
Gets the CDF of a scalar distribution.
`IntegerSpan` `getDomain()`
Returns an object that allows an iteration through the domain (x-axis, independent variable) of the Distribution
`int` `getDomainSize()`
Gets the size of the domain.
`java.lang.Integer` `getMaxSupport()`
Gets the minimum support (domain or input) of the distribution.
`java.lang.Double` `getMean()`
Gets the arithmetic mean, or "first central moment" or "expectation", of the distribution.
`double` `getMeanAsDouble()`
Gets the mean of the distribution as a double.
`java.lang.Integer` `getMinSupport()`
Gets the minimum support (domain or input) of the distribution.
`double` `getP()`
Getter for p
`BernoulliDistribution.PMF` `getProbabilityFunction()`
Gets the distribution function associated with this Distribution, either the PDF or PMF.
`double` `getVariance()`
Gets the variance of the distribution.
`boolean` `sampleAsBoolean(java.util.Random random)`
Samples from the Bernoulli distribution as a boolean.
`int` `sampleAsInt(java.util.Random random)`
Draws a single random sample from the distribution as an int.
`void` ```sampleInto(java.util.Random random, int sampleCount, java.util.Collection<? super java.lang.Number> output)```
Draws multiple random samples from the distribution and puts the result into the given collection.
`void` `setP(double p)`
Setter for p
`java.lang.String` `toString()`
• ### Methods inherited from class gov.sandia.cognition.statistics.AbstractClosedFormIntegerDistribution

`sampleAsInts, sampleInto`
• ### Methods inherited from class gov.sandia.cognition.statistics.AbstractClosedFormUnivariateDistribution

`clone`
• ### Methods inherited from class gov.sandia.cognition.statistics.AbstractDistribution

`sample, sample`
• ### Methods inherited from class java.lang.Object

`equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`
• ### Methods inherited from interface gov.sandia.cognition.statistics.Distribution

`sample, sample`
• ### Methods inherited from interface gov.sandia.cognition.math.matrix.Vectorizable

`clone`
• ### Field Detail

• #### DEFAULT_P

`public static final double DEFAULT_P`
Default Bernoulli parameter, 0.5
Constant Field Values
• ### Constructor Detail

• #### BernoulliDistribution

`public BernoulliDistribution()`
Creates a new instance of BernoulliDistribution
• #### BernoulliDistribution

`public BernoulliDistribution(double p)`
Creates a new instance of BernoulliDistribution
Parameters:
`p` - Bernoulli parameter, where the distribution takes value "1" with probability "p" and value "0" with probability 1-p.
• #### BernoulliDistribution

`public BernoulliDistribution(BernoulliDistribution other)`
Copy Constructor
Parameters:
`other` - BernoulliDistribution to copy
• ### Method Detail

• #### getMean

`public java.lang.Double getMean()`
Description copied from interface: `DistributionWithMean`
Gets the arithmetic mean, or "first central moment" or "expectation", of the distribution.
Specified by:
`getMean` in interface `DistributionWithMean<java.lang.Number>`
Returns:
Mean of the distribution.
• #### getMeanAsDouble

`public double getMeanAsDouble()`
Description copied from interface: `UnivariateDistribution`
Gets the mean of the distribution as a double.
Specified by:
`getMeanAsDouble` in interface `UnivariateDistribution<java.lang.Number>`
Returns:
The mean as a double.
• #### getMinSupport

`public java.lang.Integer getMinSupport()`
Description copied from interface: `UnivariateDistribution`
Gets the minimum support (domain or input) of the distribution.
Specified by:
`getMinSupport` in interface `UnivariateDistribution<java.lang.Number>`
Returns:
Minimum support.
• #### getMaxSupport

`public java.lang.Integer getMaxSupport()`
Description copied from interface: `UnivariateDistribution`
Gets the minimum support (domain or input) of the distribution.
Specified by:
`getMaxSupport` in interface `UnivariateDistribution<java.lang.Number>`
Returns:
Minimum support.
• #### sampleInto

```public void sampleInto(java.util.Random random,
int sampleCount,
java.util.Collection<? super java.lang.Number> output)```
Description copied from interface: `Distribution`
Draws multiple random samples from the distribution and puts the result into the given collection.
Specified by:
`sampleInto` in interface `Distribution<java.lang.Number>`
Parameters:
`random` - Random number generator to use.
`sampleCount` - The number of samples to draw. Cannot be negative.
`output` - The collection to add the samples into.
• #### sampleAsInt

`public int sampleAsInt(java.util.Random random)`
Description copied from interface: `IntegerDistribution`
Draws a single random sample from the distribution as an int.
Specified by:
`sampleAsInt` in interface `IntegerDistribution`
Parameters:
`random` - The random number generator to use.
Returns:
A sample from the distribution.
• #### sampleAsBoolean

`public boolean sampleAsBoolean(java.util.Random random)`
Samples from the Bernoulli distribution as a boolean.
Parameters:
`random` - The random number generator to use.
Returns:
A true or false value sampled from the distribution. The value is true with probability p.
• #### convertToVector

`public Vector convertToVector()`
Description copied from interface: `Vectorizable`
Converts the object to a vector.
Specified by:
`convertToVector` in interface `Vectorizable`
Returns:
The Vector form of the object.
• #### convertFromVector

`public void convertFromVector(Vector parameters)`
Description copied from interface: `Vectorizable`
Converts the object from a Vector of parameters.
Specified by:
`convertFromVector` in interface `Vectorizable`
Parameters:
`parameters` - The parameters to incorporate.
• #### getVariance

`public double getVariance()`
Description copied from interface: `UnivariateDistribution`
Gets the variance of the distribution. This is sometimes called the second central moment by more pedantic people, which is equivalent to the square of the standard deviation.
Specified by:
`getVariance` in interface `UnivariateDistribution<java.lang.Number>`
Returns:
Variance of the distribution.
• #### getDomain

`public IntegerSpan getDomain()`
Description copied from interface: `DiscreteDistribution`
Returns an object that allows an iteration through the domain (x-axis, independent variable) of the Distribution
Specified by:
`getDomain` in interface `DiscreteDistribution<java.lang.Number>`
Returns:
Collection that enumerates each value that the domain can take
• #### getDomainSize

`public int getDomainSize()`
Description copied from interface: `DiscreteDistribution`
Gets the size of the domain.
Specified by:
`getDomainSize` in interface `DiscreteDistribution<java.lang.Number>`
Returns:
The size of the domain.
• #### getP

`public double getP()`
Getter for p
Returns:
Bernoulli parameter, where the distribution takes value "1" with probability "p" and value "0" with probability 1-p.
• #### setP

`public void setP(double p)`
Setter for p
Parameters:
`p` - Bernoulli parameter, where the distribution takes value "1" with probability "p" and value "0" with probability 1-p.
• #### getCDF

`public BernoulliDistribution.CDF getCDF()`
Description copied from interface: `UnivariateDistribution`
Gets the CDF of a scalar distribution.
Specified by:
`getCDF` in interface `ClosedFormUnivariateDistribution<java.lang.Number>`
Specified by:
`getCDF` in interface `UnivariateDistribution<java.lang.Number>`
Returns:
CDF of the scalar distribution.
• #### getProbabilityFunction

`public BernoulliDistribution.PMF getProbabilityFunction()`
Description copied from interface: `ComputableDistribution`
Gets the distribution function associated with this Distribution, either the PDF or PMF.
Specified by:
`getProbabilityFunction` in interface `ComputableDistribution<java.lang.Number>`
Specified by:
`getProbabilityFunction` in interface `DiscreteDistribution<java.lang.Number>`
Returns:
Distribution function associated with this Distribution.
• #### toString

`public java.lang.String toString()`
Overrides:
`toString` in class `java.lang.Object`