perm_test¶
-
hyppo.tools.perm_test(calc_stat, x, y, z=None, reps=1000, workers=1, is_distsim=True, perm_blocks=None, random_state=None, permuter=None)¶ Permutation test for the p-value of a nonparametric test.
This process is completed by first randomly permuting \(y\) to estimate the null distribution and then calculating the probability of observing a test statistic, under the null, at least as extreme as the observed test statistic.
- Parameters
calc_stat (
callable) -- The method used to calculate the test statistic (must use hyppo API).x,y,z (
ndarrayoffloat) -- Input data matrices.x,yandzmust have the same number of samples. That is, the shapes must be(n, p),(n, q),(n, r)``where `n` is the number of samples and `p`, `q` , and `r` are the number of dimensions. Alternatively, ``xandycan be distance or similarity matrices, andzmust be a similarity matrix where the shapes must be(n, n).zis an optional matrix only used for conditional independence testing.reps (
int, default:1000) -- The number of replications used to estimate the null distribution when using the permutation test used to calculate the p-value.workers (
int, default:1) -- The number of cores to parallelize the p-value computation over. Supply-1to use all cores available to the Process.is_distsim (
bool, default:True) -- Whether or notxandyare distance or similarity matrices.perm_blocks (
ndarray, default:None) -- Defines blocks of exchangeable samples during the permutation test. IfNone, all samples can be permuted with one another. Requires n rows. Constructs a tree graph with all samples initially at the root node. Each column partitions samples from the same leaf with shared column label into a child of that leaf. During the permutation test, samples within the same final leaf node are exchangeable and blocks of samples with a common parent node are exchangeable. If a column value is negative, the resulting block is unexchangeable.permuter (
callable, default:None) -- Defines a custom permutation function. If None, the default permutation test is used.
- Returns