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

## com.singularsys.jep.functions
Class Binomial

    java.lang.Object
      com.singularsys.jep.functions.PostfixMathCommand
          com.singularsys.jep.functions.Binomial

All Implemented Interfaces:
  PostfixMathCommandI, java.io.Serializable

    public class Binomial

extends PostfixMathCommand

Binomial coefficients: binom(n,i). Requires n,i integers >=0. Often written as nCi or column vector (n,i).

The following rules apply:
(n,0) = 1, (n,1) = n, (n,n-1) = n, (n,n) = 1
(n,i) = n! / ( i! (n-i)! )
Pascals triangle rule: (n,i) = (n-1,i-1) + (n-1,i)
Binomial theorem: (a+b)^n = sum (n,i) a^i b^(n-i), i=0..n.

For efficiency the binomial coefficients are stored in a static array.

Author:
  Rich Morris Created on 13-Feb-2005
See Also:
  Serialized Form

Field Summary

Fields inherited from class com.singularsys.jep.functions.PostfixMathCommand
`curNumberOfParameters, numberOfParameters`

Constructor Summary
`Binomial()`

Method Summary
`static int` | `binom(int n, int i)` Returns the binomial coefficients.
`void` | `run(java.util.Stack<java.lang.Object> s)` Run the function on the stack.

Methods inherited from class com.singularsys.jep.functions.PostfixMathCommand
`checkNumberOfParameters, checkStack, getNumberOfParameters, setCurNumberOfParameters`

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

Constructor Detail

### Binomial

    public Binomial()

Method Detail

### run

    public void run(java.util.Stack<java.lang.Object> s)
             throws EvaluationException

  Description copied from interface: `PostfixMathCommandI`
  Run the function on the stack. Pops the arguments from the stack, and pushes the result on the top of the stack.

  Throws:
    `EvaluationException`

### binom

    public static int binom(int n,
                            int i)
                     throws java.lang.ArrayIndexOutOfBoundsException

  Returns the binomial coefficients.

  Throws:
    `java.lang.ArrayIndexOutOfBoundsException` - if n<0, i<0 or i>n

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

Copyright © 2008 Singular Systems http://www.singularsys.com/jep