All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class sdsu.algorithms.data.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 Index

 o Geometric(double)
Returns a Geometric.

Method Index

 o density(double)
Returns the probability that it takes numberOfTrials to get the first successful event.
 o mean()
Returns the mean of the distribution
 o variance()
Returns the variance of the distribution

Constructors

 o 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].

Methods

 o 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
 o mean
 public double mean()
Returns the mean of the distribution

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

Overrides:
variance in class Bernoulli

All Packages  Class Hierarchy  This Package  Previous  Next  Index