This is a pre-release version (2.0.0.dev0+git20260907.41eeb59).Go to latest (1.18.0)
{ } Raw JSON

bundles / scipy 2.0.0.dev0+git20260907.41eeb59 / scipy / stats / _multivariate / random_table_gen / rvs

function

scipy.stats._multivariate:random_table_gen.rvs

source: build-install/usr/lib/python3.14/site-packages/scipy/stats/_multivariate.py:6330

Signature

def rvs(self, row, col, *, size = None, method = None, random_state = None)

Summary

Draw random tables with fixed column and row marginals.

Parameters

row : array_like

Sum of table entries in each row.

col : array_like

Sum of table entries in each column.

size : int, optional

Number of samples to draw (default 1).

method : str, optional

Which method to use, "boyett" or "patefield". If None (default), selects the fastest method for this input.

seed : {None, int, np.random.RandomState, np.random.Generator}, optional

Used for drawing random variates. If seed is None, the ~np.random.RandomState singleton is used. If seed is an int, a new RandomState instance is used, seeded with seed. If seed is already a RandomState or Generator instance, then that object is used. Default is None.

Returns

rvs : ndarray

Random 2D tables of shape (size, len(row), len(col)).

Notes

The row and column vectors must be one-dimensional, not empty, and each sum up to the same value. They cannot contain negative or noninteger entries.

Examples

from scipy.stats import random_table
✓
row = [1, 5]
col = [2, 3, 1]
✓
random_table.rvs(row, col, random_state=123)
✗
array([[1, 0, 0],
       [1, 3, 1]])
Alternatively, the object may be called (as a function) to fix the row and column vector sums, returning a "frozen" distribution.
d = random_table(row, col)
✓
d.rvs(random_state=123)
✗
array([[1, 0, 0],
       [1, 3, 1]])

Aliases

  • scipy.stats._multivariate.random_table_gen.rvs