Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## baseCode.math
Class SpecFunc

    java.lang.Object
      baseCode.math.SpecFunc

public class SpecFunc
extends java.lang.Object

Assorted special functions, primarily concerning probability distributions. For cumBinomial use cern.jet.stat.Probability.binomial.

Mostly ported from the R source tree (dhyper.c etc.), much due to Catherine Loader.

Version:
  $Id: SpecFunc.java,v 1.7 2004/12/24 23:16:09 pavlidis Exp $
Author:
  Paul Pavlidis
See Also:
  cern.jet.stat.gamma , cern.jet.math.arithmetic

  Copyright (c) 2004 Columbia University

Constructor Summary
`SpecFunc()`

Method Summary
`static double` | `dbinom(double x, double n, double p)` See dbinom_raw.
`static double` | `dhyper(int x, int r, int b, int n)` Ported from R (Catherine Loader)
`static double` | `phyper(int x, int NR, int NB, int n, boolean lowerTail)` Ported from R phyper.c

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### SpecFunc

    public SpecFunc()

Method Detail

### phyper

    public static double phyper(int x,
                                int NR,
                                int NB,
                                int n,
                                boolean lowerTail)

  Ported from R phyper.c

  Sample of n balls from NR red and NB black ones; x are red

  Parameters:
    `x` - - number of reds retrieved == successes
    `NR` - - number of reds in the urn. == positives
    `NB` - - number of blacks in the urn == negatives
    `n` - - the total number of objects drawn == successes + failures
    `lowerTail` -
  Returns:
    cumulative hypergeometric distribution.

### dhyper

    public static double dhyper(int x,
                                int r,
                                int b,
                                int n)

  Ported from R (Catherine Loader)

  DESCRIPTION

  Given a sequence of r successes and b failures, we sample n (\le b+r) items without replacement. The hypergeometric probability is the probability of x successes:

                           choose(r, x) * choose(b, n-x)
                 p(x; r,b,n) =  -----------------------------  =
                              choose(r+b, n)

                          dbinom(x,r,p) * dbinom(n-x,b,p)
                        = --------------------------------
                              dbinom(n,r+b,p)

  for any p. For numerical stability, we take p=n/(r+b); with this choice, the denominator is not exponentially small.

### dbinom

    public static double dbinom(double x,
                                double n,
                                double p)

  See dbinom_raw.

  Parameters:
    `x` - Number of successes
    `n` - Number of trials
    `p` - Probability of success
  Returns:

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2003-2005 Columbia University. All Rights Reserved.