sdsu.algorithms.data
Class Geometric

java.lang.Object
  |
  +--sdsu.algorithms.data.ProbabilityDistribution
        |
        +--sdsu.algorithms.data.DiscreteProbability
              |
              +--sdsu.algorithms.data.Bernoulli
                    |
                    +--sdsu.algorithms.data.Geometric

public class Geometric
extends Bernoulli

The Geometric distribution deals with Bernoulli like situations: the sample space is divided into success events and failure events. The geometric distributions answers questions about how many trials are required to get a successful event. The density function maps an integer N to the probability that it requires N trials to get the first success. The nextElement() returns the number of trials needed to get a success in a sequence of random trials. This class is adapted from Smalltalk-80: The language and Its Implementation, Goldberg & Robson, Addison-Wesley, 1983, chapter 21, pages 417-438.

Version:
1.0 10 June 1997
Author:
Roger Whitney (whitney@cs.sdsu.edu)

Constructor Summary
Geometric(double successProbability)
          Returns a Geometric.
 
Method Summary
 double density(double numberOfTrials)
          Returns the probability that it takes numberOfTrials to get the first successful event.
 double mean()
          Returns the mean of the distribution
 double variance()
          Returns the variance of the distribution
 
Methods inherited from class sdsu.algorithms.data.Bernoulli
nextElement
 
Methods inherited from class sdsu.algorithms.data.DiscreteProbability
distribution
 
Methods inherited from class sdsu.algorithms.data.ProbabilityDistribution
density
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Geometric

public Geometric(double successProbability)
          throws OutOfBoundsException
Returns a Geometric.
Parameters:
successProbability - the probability of a successful event.
Throws:
OutOfBoundsException - thrown if successProbability is not in the interval [0, 1].
Method Detail

density

public double density(double numberOfTrials)
               throws OutOfBoundsException
Returns the probability that it takes numberOfTrials to get the first successful event.
Parameters:
numberOfTrials - an integer number of trials. Will be converted to an int. Must be greater than 0.
Overrides:
density in class Bernoulli

mean

public double mean()
Returns the mean of the distribution
Overrides:
mean in class Bernoulli

variance

public double variance()
Returns the variance of the distribution
Overrides:
variance in class Bernoulli