Returns the n x n Pascal matrix.
The Pascal matrix is a matrix containing the binomial coefficients as its elements.
New in version 0.11.0.
Parameters : | n : int
kind : str, optional
exact : bool, optional
|
---|---|
Returns : | p : (n, n) ndarray
|
Notes
See http://en.wikipedia.org/wiki/Pascal_matrix for more information about Pascal matrices.
Examples
>>> from scipy.linalg import pascal
>>> pascal(4)
array([[ 1, 1, 1, 1],
[ 1, 2, 3, 4],
[ 1, 3, 6, 10],
[ 1, 4, 10, 20]], dtype=uint64)
>>> pascal(4, kind='lower')
array([[1, 0, 0, 0],
[1, 1, 0, 0],
[1, 2, 1, 0],
[1, 3, 3, 1]], dtype=uint64)
>>> pascal(50)[-1, -1]
25477612258980856902730428600L
>>> from scipy.misc import comb
>>> comb(98, 49, exact=True)
25477612258980856902730428600L