bundles / scipy 1.17.1 / scipy / stats / _multivariate / random_table_gen
class
scipy.stats._multivariate:random_table_gen
Signature
class random_table_gen ( seed = None ) Members
-
__call__ -
__init__ -
_process_parameters -
_process_rvs_method -
_process_size_shape -
_rvs_boyett -
_rvs_patefield -
_rvs_select -
logpmf -
mean -
pmf -
rvs
Summary
Contingency tables from independent samples with fixed marginal sums.
Extended Summary
This is the distribution of random tables with given row and column vector sums. This distribution represents the set of random tables under the null hypothesis that rows and columns are independent. It is used in hypothesis tests of independence.
Because of assumed independence, the expected frequency of each table element can be computed from the row and column sums, so that the distribution is completely determined by these two vectors.
Parameters
row: array_likeSum of table entries in each row.
col: array_likeSum of table entries in each column.
seed: {None, int, np.random.RandomState, np.random.Generator}, optionalUsed for drawing random variates. If
seedisNone, the~np.random.RandomStatesingleton is used. Ifseedis an int, a newRandomStateinstance is used, seeded with seed. Ifseedis already aRandomStateorGeneratorinstance, then that object is used. Default isNone.
Methods
logpmf(x)Log-probability of table
xto occur in the distribution.pmf(x)Probability of table
xto occur in the distribution.mean(row, col)Mean table.
rvs(row, col, size=None, method=None, random_state=None)Draw random tables with given row and column vector sums.
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.
Random elements from the distribution are generated either with Boyett's [1] or Patefield's algorithm [2]. Boyett's algorithm has O(N) time and space complexity, where N is the total sum of entries in the table. Patefield's algorithm has O(K x log(N)) time complexity, where K is the number of cells in the table and requires only a small constant work space. By default, the rvs method selects the fastest algorithm based on the input, but you can specify the algorithm with the keyword method. Allowed values are "boyett" and "patefield".
Examples
from scipy.stats import random_table
✓row = [1, 5] col = [2, 3, 1]✓
random_table.mean(row, col)
✗dist = random_table(row, col) dist.rvs(random_state=123)✓
Aliases
-
scipy.stats._multivariate.random_table_gen