scipy 1.8.0 Pypi GitHub Homepage
Other Docs
NotesParametersReturnsBackRef
pascal(n, kind='symmetric', exact=True)

The Pascal matrix is a matrix containing the binomial coefficients as its elements.

Notes

See https://en.wikipedia.org/wiki/Pascal_matrix for more information about Pascal matrices.

versionadded

Parameters

n : int

The size of the matrix to create; that is, the result is an n x n matrix.

kind : str, optional

Must be one of 'symmetric', 'lower', or 'upper'. Default is 'symmetric'.

exact : bool, optional

If :None:None:`exact` is True, the result is either an array of type numpy.uint64 (if n < 35) or an object array of Python long integers. If :None:None:`exact` is False, the coefficients in the matrix are computed using scipy.special.comb with :None:None:`exact=False`. The result will be a floating point array, and the values in the array will not be the exact coefficients, but this version is much faster than :None:None:`exact=True`.

Returns

p : (n, n) ndarray

The Pascal matrix.

Returns the n x n Pascal matrix.

See Also

invpascal

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]
25477612258980856902730428600
>>> from scipy.special import comb
... comb(98, 49, exact=True) 25477612258980856902730428600
See :

Back References

The following pages refer to to this document either explicitly or contain code examples using this.

scipy.linalg._special_matrices.invpascal scipy.linalg._special_matrices.pascal

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


GitHub : /scipy/linalg/_special_matrices.py#776
type: <class 'function'>
Commit: