net.sourceforge.domian.test.combinatorics
Class Combinatorics

java.lang.Object
  extended by net.sourceforge.domian.test.combinatorics.Combinatorics

public final class Combinatorics
extends java.lang.Object

This class contains methods for performing basic combinatoric operations such as calculating numbers of permutations and combinations.

Author:
Eirik Torske

Constructor Summary
Combinatorics()
           
 
Method Summary
static java.math.BigInteger C(int m, int n)
          Calculates the number of combinations (math:"n over m") of n elements chosen from a list of m elements.
static void check(int m, int n)
          Checks that 0 <= n <= m.
static java.math.BigInteger factorial(int n)
          Calculates the factorial (math: !)
static java.math.BigInteger P(int n)
          Calculates the number of possible orderings of n elements where each element can only appear once (permutations), chosen from list of m elements (m set equal to n).
static java.math.BigInteger P(int m, int n)
          Calculates the number of possible orderings of n elements where each element can only appear once (permutations), chosen from list of m elements.
static java.math.BigInteger S(int m, int n)
          Calculates the number of possible orderings of n elements, chosen from list of m elements.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Combinatorics

public Combinatorics()
Method Detail

check

public static void check(int m,
                         int n)
Checks that 0 <= n <= m.


factorial

public static java.math.BigInteger factorial(int n)
Calculates the factorial (math: !) of n , the product of the natural numbers 1 ... n.
(no: "fakultetet av n")

Parameters:
n - the ... damn, what was the name of this mathematical entity again?
Returns:
n factorial.

S

public static java.math.BigInteger S(int m,
                                     int n)
Calculates the number of possible orderings of n elements, chosen from list of m elements.

no: "Urnemodell - Ordnet utvalg med tilbakelegging"

Med "ordnet" menes det at rekkefølgen som elementene er ordnet etter tas hensyn til.
Med "med tilbakelegging" menes det at elementene kan forekomme mer enn en gang.

S(m,n) = m^n

Parameters:
m - the number of elements to use within each number sequence.
n - the length of the number sequence list.
Returns:
the number of possible orderings of n elements chosen from a list of m elements.

P

public static java.math.BigInteger P(int n)
Calculates the number of possible orderings of n elements where each element can only appear once (permutations), chosen from list of m elements (m set equal to n).

no: "Urnemodell - Ordnet utvalg uten tilbakelegging"

Med "ordnet" menes det at rekkefølgen som elementene er ordnet etter tas hensyn til.
Med "uten tilbakelegging" menes det at ingen elementer kan forekomme mer enn en gang.

S(n,n) = n!/(n-n)! = n!/1 = n!

Parameters:
n - the length of the permutation list.
Returns:
the number of possible orderings of n elements.

P

public static java.math.BigInteger P(int m,
                                     int n)
Calculates the number of possible orderings of n elements where each element can only appear once (permutations), chosen from list of m elements.

no: "Urnemodell - Ordnet utvalg uten tilbakelegging"

Med "ordnet" menes det at rekkefølgen som elementene er ordnet etter tas hensyn til.
Med "uten tilbakelegging" menes det at ingen elementer kan forekomme mer enn en gang.

S(m,n) = n * (n-1) * ... * (n-m+1) = n!/(n-m)!

Parameters:
m - the number of elements to use within each permutation.
n - the length of the permutation list.
Returns:
the number of possible orderings of n elements chosen from a list of m elements.

C

public static java.math.BigInteger C(int m,
                                     int n)
Calculates the number of combinations (math:"n over m") of n elements chosen from a list of m elements.

no: "Urnemodell - Uordnet utvalg uten tilbakelegging"

Med "uordnet" menes det at rekkefølgen som elementene er ordnet etter er uinteressant.
Med "uten tilbakelegging" menes det at ingen elementer kan forekomme mer enn en gang.

C(m,n) = n!/(m!*(n-m)!) = S(n,m)/m!

Parameters:
m - the number of elements to use within each combination.
n - length of the combination list.
Returns:
the number of combinations of n elements chosen from a list of m elements.


Copyright © 2008-2010. All Rights Reserved.