In [3]:
%%classpath add mvn
org.apache.commons commons-math3 3.6.1
In [4]:
import org.apache.commons.math3.util.CombinatoricsUtils._
Out[4]:
binomialCoefficient¶
In [5]:
binomialCoefficient(5, 3)
Out[5]:
In [6]:
binomialCoefficientDouble(5, 3)
Out[6]:
In [7]:
binomialCoefficientLog(5, 3)
Out[7]:
In [8]:
checkBinomial(5, 3)
combinationsIterator¶
Notice that this methods returns an iterator of the type java.util.Iterator[Array[Int]], which is not a Scala Iterator! For combinations/permutations iterator, it is suggested that you use Seq.combinations and/or Seq.permutations.
In [10]:
val it = combinationsIterator(5, 3)
Out[10]:
Factorial¶
In [11]:
factorial(10)
Out[11]:
In [14]:
factorial(100)
In [15]:
factorialDouble(100)
Out[15]:
In [16]:
factorialDouble(20)
Out[16]:
In [17]:
factorialLog(100)
Out[17]:
Stirling¶
In [18]:
stirlingS2(10, 3)
Out[18]:
In [ ]: