Random data#
The spm1d.rng module generates random 0D and 1D datasets with user-specified means, variances, smoothness and non-sphericity for most functions in spm1d.stats. Each function returns a single dataset whose outputs can be submitted directly to the corresponding spm1d.stats procedure. Classes (e.g., spm1d.rng.ANOVA1RM) are also available to iteratively generate many datasets from a single model.
RNG functions#
- ttest(*args, **kwargs)#
Generate one random dataset from TTEST.
One-sample t test (Hotelling’s T2 if ncomp > 1).
- Parameters:
The arguments of
spm1d.rng.TTEST. Use that class directly to draw many datasets from one model
- Returns:
The data as a tuple
(Y, *factors, *covariates, SUBJ)omitting whatever the design does not contain
- Example:
A random 1D dataset (eight observations, 101 nodes, FWHM 20) analyzed with the spm1d.stats procedure of the same name.
>>> import spm1d >>> y, = spm1d.rng.ttest( nsubj=8, Q=101, fwhm=20, seed=0 ) >>> print( y.shape ) (8, 101) >>> spmi = spm1d.stats.ttest( y ).inference( 0.05 )
- ttest_paired(*args, **kwargs)#
Generate one random dataset from TTEST_PAIRED.
Paired t test (Hotelling’s T2 if ncomp > 1).
- Parameters:
The arguments of
spm1d.rng.TTEST_PAIRED. Use that class directly to draw many datasets from one model
- Returns:
The data as a tuple
(Y, *factors, *covariates, SUBJ)omitting whatever the design does not contain
- Example:
A random 1D dataset (eight subjects, two conditions) analyzed with the spm1d.stats procedure of the same name.
>>> import spm1d >>> y0, y1 = spm1d.rng.ttest_paired( nsubj=8, Q=101, fwhm=20, seed=0 ) >>> print( y0.shape, y1.shape ) (8, 101) (8, 101) >>> spmi = spm1d.stats.ttest_paired( y0, y1 ).inference( 0.05 )
- ttest2(*args, **kwargs)#
Generate one random dataset from TTEST2.
Two-sample t test (Hotelling’s T2 if ncomp > 1).
- Parameters:
The arguments of
spm1d.rng.TTEST2. Use that class directly to draw many datasets from one model
- Returns:
The data as a tuple
(Y, *factors, *covariates, SUBJ)omitting whatever the design does not contain
- Example:
A random 1D dataset (two groups of eight) analyzed with the spm1d.stats procedure of the same name.
>>> import spm1d >>> y0, y1 = spm1d.rng.ttest2( nsubj=8, Q=101, fwhm=20, seed=0 ) >>> print( y0.shape, y1.shape ) (8, 101) (8, 101) >>> spmi = spm1d.stats.ttest2( y0, y1 ).inference( 0.05 )
- regress(*args, **kwargs)#
Generate one random dataset from Regression.
Random dataset generator for regression with continuous predictors only.
- Parameters:
The arguments of
spm1d.rng.Regression. Use that class directly to draw many datasets from one model
- Returns:
The data as a tuple
(Y, *factors, *covariates, SUBJ)omitting whatever the design does not contain
- Example:
A random 1D dataset (12 observations and one independent variable) analyzed with the spm1d.stats procedure of the same name.
>>> import spm1d >>> y, x = spm1d.rng.regress( J=12, Q=101, fwhm=20, seed=0 ) >>> print( y.shape, x.shape ) (12, 101) (12,) >>> spmi = spm1d.stats.regress( y, x ).inference( 0.05 )
- anova(*args, **kwargs)#
Generate one random dataset from ANOVA.
Random dataset generator for n-way ANOVA designs.
- Parameters:
The arguments of
spm1d.rng.ANOVA. Use that class directly to draw many datasets from one model
- Returns:
The data as a tuple
(Y, *factors, *covariates, SUBJ)omitting whatever the design does not contain
- Example:
A random 1D dataset from a 2 x 3 design with factor B within subjects (eight subjects per level of A) analyzed with spm1d.stats.anova2onerm.
>>> import spm1d >>> y, A, B, SUBJ = spm1d.rng.anova( nlevels=(2, 3), rm='B', nsubj=8, Q=101, fwhm=20, seed=0 ) >>> print( y.shape, A.shape, B.shape, SUBJ.shape ) (48, 101) (48,) (48,) (48,) >>> spmi = spm1d.stats.anova2onerm( y, A, B, SUBJ ).inference( 0.05 )
- anova1(*args, **kwargs)#
Generate one random dataset from ANOVA1.
One-way between-subject ANOVA. nsubj is the number of observations per group.
- Parameters:
The arguments of
spm1d.rng.ANOVA1. Use that class directly to draw many datasets from one model
- Returns:
The data as a tuple
(Y, *factors, *covariates, SUBJ)omitting whatever the design does not contain
- Example:
A random 1D dataset (three groups of eight) analyzed with the spm1d.stats procedure of the same name.
>>> import spm1d >>> y, A = spm1d.rng.anova1( nlevels=3, nsubj=8, Q=101, fwhm=20, seed=0 ) >>> print( y.shape, A.shape ) (24, 101) (24,) >>> spmi = spm1d.stats.anova1( y, A ).inference( 0.05 )
- anova1rm(*args, **kwargs)#
Generate one random dataset from ANOVA1RM.
One-way repeated-measures ANOVA. nsubj is the number of subjects.
- Parameters:
The arguments of
spm1d.rng.ANOVA1RM. Use that class directly to draw many datasets from one model
- Returns:
The data as a tuple
(Y, *factors, *covariates, SUBJ)omitting whatever the design does not contain
- Example:
A random 1D dataset (eight subjects, three conditions) analyzed with the spm1d.stats procedure of the same name.
>>> import spm1d >>> y, A, SUBJ = spm1d.rng.anova1rm( nlevels=3, nsubj=8, Q=101, fwhm=20, seed=0 ) >>> print( y.shape ) (24, 101) >>> spmi = spm1d.stats.anova1rm( y, A, SUBJ ).inference( 0.05 )
- anova2(*args, **kwargs)#
Generate one random dataset from ANOVA2.
Two-way between-subject ANOVA. nsubj is the number of observations per cell.
- Parameters:
The arguments of
spm1d.rng.ANOVA2. Use that class directly to draw many datasets from one model
- Returns:
The data as a tuple
(Y, *factors, *covariates, SUBJ)omitting whatever the design does not contain
- Example:
A random 1D dataset (2 x 3 design, five observations per cell) analyzed with the spm1d.stats procedure of the same name.
>>> import spm1d >>> y, A, B = spm1d.rng.anova2( nlevels=(2, 3), nsubj=5, Q=101, fwhm=20, seed=0 ) >>> print( y.shape ) (30, 101) >>> spmi = spm1d.stats.anova2( y, A, B ).inference( 0.05 )
- anova2onerm(*args, **kwargs)#
Generate one random dataset from ANOVA2ONERM.
Two-way ANOVA with repeated measures on the second factor (B).
- Parameters:
The arguments of
spm1d.rng.ANOVA2ONERM. Use that class directly to draw many datasets from one model
- Returns:
The data as a tuple
(Y, *factors, *covariates, SUBJ)omitting whatever the design does not contain
- Example:
A random 1D dataset (2 x 3 mixed design, five subjects per group) analyzed with the spm1d.stats procedure of the same name.
>>> import spm1d >>> y, A, B, SUBJ = spm1d.rng.anova2onerm( nlevels=(2, 3), nsubj=5, Q=101, fwhm=20, seed=0 ) >>> print( y.shape ) (30, 101) >>> spmi = spm1d.stats.anova2onerm( y, A, B, SUBJ ).inference( 0.05 )
- anova2rm(*args, **kwargs)#
Generate one random dataset from ANOVA2RM.
Two-way repeated-measures ANOVA (both factors repeated).
- Parameters:
The arguments of
spm1d.rng.ANOVA2RM. Use that class directly to draw many datasets from one model
- Returns:
The data as a tuple
(Y, *factors, *covariates, SUBJ)omitting whatever the design does not contain
- Example:
A random 1D dataset (2 x 3 repeated-measures design, five subjects) analyzed with the spm1d.stats procedure of the same name.
>>> import spm1d >>> y, A, B, SUBJ = spm1d.rng.anova2rm( nlevels=(2, 3), nsubj=5, Q=101, fwhm=20, seed=0 ) >>> print( y.shape ) (30, 101) >>> spmi = spm1d.stats.anova2rm( y, A, B, SUBJ ).inference( 0.05 )
- anova3(*args, **kwargs)#
Generate one random dataset from ANOVA3.
Three-way between-subject ANOVA.
- Parameters:
The arguments of
spm1d.rng.ANOVA3. Use that class directly to draw many datasets from one model
- Returns:
The data as a tuple
(Y, *factors, *covariates, SUBJ)omitting whatever the design does not contain
- Example:
A random 1D dataset (2 x 2 x 2 design, five observations per cell) analyzed with the spm1d.stats procedure of the same name.
>>> import spm1d >>> y, A, B, C = spm1d.rng.anova3( nlevels=(2, 2, 2), nsubj=5, Q=101, fwhm=20, seed=0 ) >>> print( y.shape ) (40, 101) >>> spmi = spm1d.stats.anova3( y, A, B, C ).inference( 0.05 )
- anova3onerm(*args, **kwargs)#
Generate one random dataset from ANOVA3ONERM.
Three-way ANOVA with repeated measures on the third factor (C).
- Parameters:
The arguments of
spm1d.rng.ANOVA3ONERM. Use that class directly to draw many datasets from one model
- Returns:
The data as a tuple
(Y, *factors, *covariates, SUBJ)omitting whatever the design does not contain
- Example:
A random 1D dataset (2 x 2 x 2 mixed design, five subjects per cell) analyzed with the spm1d.stats procedure of the same name.
>>> import spm1d >>> y, A, B, C, SUBJ = spm1d.rng.anova3onerm( nlevels=(2, 2, 2), nsubj=5, Q=101, fwhm=20, seed=0 ) >>> print( y.shape ) (40, 101) >>> spmi = spm1d.stats.anova3onerm( y, A, B, C, SUBJ ).inference( 0.05 )
- anova3rm(*args, **kwargs)#
Generate one random dataset from ANOVA3RM.
Three-way repeated-measures ANOVA (all factors repeated).
- Parameters:
The arguments of
spm1d.rng.ANOVA3RM. Use that class directly to draw many datasets from one model
- Returns:
The data as a tuple
(Y, *factors, *covariates, SUBJ)omitting whatever the design does not contain
- Example:
A random 1D dataset (2 x 2 x 2 repeated-measures design, five subjects) analyzed with the spm1d.stats procedure of the same name.
>>> import spm1d >>> y, A, B, C, SUBJ = spm1d.rng.anova3rm( nlevels=(2, 2, 2), nsubj=5, Q=101, fwhm=20, seed=0 ) >>> print( y.shape ) (40, 101) >>> spmi = spm1d.stats.anova3rm( y, A, B, C, SUBJ ).inference( 0.05 )
- anova3tworm(*args, **kwargs)#
Generate one random dataset from ANOVA3TWORM.
Three-way ANOVA with repeated measures on the second and third factors (B, C).
- Parameters:
The arguments of
spm1d.rng.ANOVA3TWORM. Use that class directly to draw many datasets from one model
- Returns:
The data as a tuple
(Y, *factors, *covariates, SUBJ)omitting whatever the design does not contain
- Example:
A random 1D dataset (2 x 2 x 2 mixed design, five subjects per group) analyzed with the spm1d.stats procedure of the same name.
>>> import spm1d >>> y, A, B, C, SUBJ = spm1d.rng.anova3tworm( nlevels=(2, 2, 2), nsubj=5, Q=101, fwhm=20, seed=0 ) >>> print( y.shape ) (40, 101) >>> spmi = spm1d.stats.anova3tworm( y, A, B, C, SUBJ ).inference( 0.05 )
- ancova(*args, **kwargs)#
Generate one random dataset from ANCOVA.
Random dataset generator for ANCOVA designs.
- Parameters:
The arguments of
spm1d.rng.ANCOVA. Use that class directly to draw many datasets from one model
- Returns:
The data as a tuple
(Y, *factors, *covariates, SUBJ)omitting whatever the design does not contain
- Example:
A random 1D dataset (three groups of eight and one covariate) analyzed with the spm1d.stats procedure of the same name.
>>> import spm1d >>> y, A, x = spm1d.rng.ancova( nlevels=3, nsubj=8, Q=101, fwhm=20, seed=0 ) >>> print( y.shape, A.shape, x.shape ) (24, 101) (24,) (24,) >>> spmi = spm1d.stats.ancova( y, A, x ).inference( 0.05 )
- hotellings(*args, **kwargs)#
Generate one random multivariate dataset from TTEST.
- Parameters:
The arguments of
spm1d.rng.TTEST. ncomp is the number of vector components (default 3)
- Returns:
The data as the tuple that the spm1d.stats procedure of the same name takes
- Example:
A random 1D dataset (eight observations, three components) analyzed with the spm1d.stats procedure of the same name.
>>> import spm1d >>> y, = spm1d.rng.hotellings( nsubj=8, Q=101, fwhm=20, seed=0 ) >>> print( y.shape ) (8, 101, 3) >>> spmi = spm1d.stats.hotellings( y ).inference( 0.05 )
- hotellings_paired(*args, **kwargs)#
Generate one random multivariate dataset from TTEST_PAIRED.
- Parameters:
The arguments of
spm1d.rng.TTEST_PAIRED. ncomp is the number of vector components (default 3)
- Returns:
The data as the tuple that the spm1d.stats procedure of the same name takes
- Example:
A random 1D dataset (eight subjects, two conditions, three components) analyzed with the spm1d.stats procedure of the same name.
>>> import spm1d >>> y0, y1 = spm1d.rng.hotellings_paired( nsubj=8, Q=101, fwhm=20, seed=0 ) >>> print( y0.shape, y1.shape ) (8, 101, 3) (8, 101, 3) >>> spmi = spm1d.stats.hotellings_paired( y0, y1 ).inference( 0.05 )
- hotellings2(*args, **kwargs)#
Generate one random multivariate dataset from TTEST2.
- Parameters:
The arguments of
spm1d.rng.TTEST2. ncomp is the number of vector components (default 3)
- Returns:
The data as the tuple that the spm1d.stats procedure of the same name takes
- Example:
A random 1D dataset (two groups of eight, three components) analyzed with the spm1d.stats procedure of the same name.
>>> import spm1d >>> y0, y1 = spm1d.rng.hotellings2( nsubj=8, Q=101, fwhm=20, seed=0 ) >>> print( y0.shape, y1.shape ) (8, 101, 3) (8, 101, 3) >>> spmi = spm1d.stats.hotellings2( y0, y1 ).inference( 0.05 )
- manova1(*args, **kwargs)#
Generate one random multivariate dataset from ANOVA1.
- Parameters:
The arguments of
spm1d.rng.ANOVA1. ncomp is the number of vector components (default 3)
- Returns:
The data as the tuple that the spm1d.stats procedure of the same name takes
- Example:
A random 1D dataset (three groups of eight, three components) analyzed with the spm1d.stats procedure of the same name.
>>> import spm1d >>> y, A = spm1d.rng.manova1( nlevels=3, nsubj=8, Q=101, fwhm=20, seed=0 ) >>> print( y.shape ) (24, 101, 3) >>> spmi = spm1d.stats.manova1( y, A ).inference( 0.05 )
- manova2(*args, **kwargs)#
Generate one random multivariate dataset from ANOVA2.
- Parameters:
The arguments of
spm1d.rng.ANOVA2. ncomp is the number of vector components (default 3)
- Returns:
The data as the tuple that the spm1d.stats procedure of the same name takes
- Example:
A random 1D dataset (2 x 3 design, three components) analyzed with the spm1d.stats procedure of the same name.
>>> import spm1d >>> y, A, B = spm1d.rng.manova2( nlevels=(2, 3), nsubj=5, Q=101, fwhm=20, seed=0 ) >>> print( y.shape ) (30, 101, 3) >>> spmi = spm1d.stats.manova2( y, A, B ).inference( 0.05 )
- manova3(*args, **kwargs)#
Generate one random multivariate dataset from ANOVA3.
- Parameters:
The arguments of
spm1d.rng.ANOVA3. ncomp is the number of vector components (default 3)
- Returns:
The data as the tuple that the spm1d.stats procedure of the same name takes
- Example:
A random 1D dataset (2 x 2 x 2 design, three components) analyzed with the spm1d.stats procedure of the same name.
>>> import spm1d >>> y, A, B, C = spm1d.rng.manova3( nlevels=(2, 2, 2), nsubj=5, Q=101, fwhm=20, seed=0 ) >>> print( y.shape ) (40, 101, 3) >>> spmi = spm1d.stats.manova3( y, A, B, C ).inference( 0.05 )
- mancova(*args, **kwargs)#
Generate one random multivariate dataset from ANCOVA.
- Parameters:
The arguments of
spm1d.rng.ANCOVA. ncomp is the number of vector components (default 3)
- Returns:
The data as the tuple that the spm1d.stats procedure of the same name takes
- Example:
A random 1D dataset (three groups of eight, three components, one covariate) analyzed with the spm1d.stats procedure of the same name.
>>> import spm1d >>> y, A, x = spm1d.rng.mancova( nlevels=3, nsubj=8, Q=101, fwhm=20, seed=0 ) >>> print( y.shape, x.shape ) (24, 101, 3) (24,) >>> spmi = spm1d.stats.mancova( y, A, x ).inference( 0.05 )
- cca(*args, **kwargs)#
Generate one random multivariate dataset from Regression.
- Parameters:
The arguments of
spm1d.rng.Regression. ncomp is the number of vector components (default 3)
- Returns:
The data as the tuple that the spm1d.stats procedure of the same name takes
- Example:
A random 1D dataset (12 observations, three components, one independent variable) analyzed with the spm1d.stats procedure of the same name.
>>> import spm1d >>> y, x = spm1d.rng.cca( J=12, Q=101, fwhm=20, seed=0 ) >>> print( y.shape, x.shape ) (12, 101, 3) (12,) >>> spmi = spm1d.stats.cca( y, x ).inference( 0.05 )
Utilities#
- compound_symmetry(k, rho)[source]#
Compound-symmetric covariance with unit variances and constant correlation rho.
- Parameters:
k — number of levels
rho — common correlation in (-1 / (k - 1), 1)
- Returns:
(k,k) covariance matrix
- Example:
>>> import spm1d >>> S = spm1d.rng.compound_symmetry( 3, 0.5 ) >>> print( S ) [[1. 0.5 0.5] [0.5 1. 0.5] [0.5 0.5 1. ]] >>> print( spm1d.rng.epsilon( S ) ) 1.0
- Note:
Use
ar1()orfrom_epsilon()for non-spherical covariance.
- ar1(k, rho)[source]#
First-order autoregressive covariance
S[i,j] = rho ** |i - j|.- Parameters:
k — number of levels
rho — autocorrelation in (-1, 1)
- Returns:
(k,k) covariance matrix
- Example:
>>> import spm1d >>> S = spm1d.rng.ar1( 3, 0.5 ) >>> print( S ) [[1. 0.5 0.25] [0.5 1. 0.5 ] [0.25 0.5 1. ]] >>> print( round( spm1d.rng.epsilon( S ), 3 ) ) 0.925
- epsilon(S)[source]#
Greenhouse-Geisser epsilon of a covariance matrix.
- Parameters:
S — (k,k) covariance matrix
- Returns:
Epsilon (float).
- Example:
>>> import spm1d >>> S = spm1d.rng.ar1( 4, 0.8 ) >>> print( round( spm1d.rng.epsilon( S ), 3 ) ) 0.724
- from_epsilon(k, eps)[source]#
Covariance with a specified Greenhouse-Geisser epsilon.
Variances are normalized to average 1.
- Parameters:
k — number of levels
eps — target epsilon in
[1/(k-1), 1]
- Returns:
(k,k) covariance matrix
- Example:
>>> import spm1d >>> S = spm1d.rng.from_epsilon( 3, 0.7 ) >>> print( round( spm1d.rng.epsilon( S ), 3 ) ) 0.7 >>> y, A, SUBJ = spm1d.rng.anova1rm( nlevels=3, nsubj=8, cov=S, seed=0 ) # 0D data with that covariance
- estimate_fwhm(Y)[source]#
Estimate FWHM of a set of continua.
- Parameters:
Y — (J,Q) array or (J,Q,I) array of vector-valued continua
- Returns:
Estimated FWHM (float).
- Example:
Smoothness of ten simulated responses from Pataky et al. (2015).
>>> import spm1d >>> import jikudata as jd >>> y = jd.SimulatedPataky2015a().y # (10,101) array >>> print( round( spm1d.rng.estimate_fwhm( y ), 2 ) ) 26.92
The example datasets require the jiku-data package:
pip install "spm1d[data]".
- estimate_lkc(Y)[source]#
Estimate Lipschitz-Killing curvature of a set of continua (
estimate_fwhmconverted withfwhm2lkc).- Parameters:
Y — (J,Q) array or (J,Q,I) array of vector-valued continua
- Returns:
Estimated LKC (float).
- Example:
Lipschitz-Killing curvature of ten simulated responses from Pataky et al. (2015).
>>> import spm1d >>> import jikudata as jd >>> y = jd.SimulatedPataky2015a().y # (10,101) array >>> print( round( spm1d.rng.estimate_lkc( y ), 3 ) ) 6.186
The example datasets require the jiku-data package:
pip install "spm1d[data]".
- fwhm2lkc(fwhm, Q)[source]#
Convert FWHM to Lipschitz-Killing curvature for a continuum of Q nodes (same as
spm1d.geom.fwhm2lkc()).- Parameters:
fwhm — smoothness in nodes (positive)
Q — number of continuum nodes
- Returns:
Lipschitz-Killing curvature (float)
- Example:
>>> import spm1d >>> print( round( spm1d.rng.fwhm2lkc( 20, 101 ), 3 ) ) 8.326
- lkc2fwhm(lkc, Q)[source]#
Convert Lipschitz-Killing curvature to FWHM for a continuum of Q nodes (same as
spm1d.geom.lkc2fwhm()).- Parameters:
lkc — Lipschitz-Killing curvature (positive)
Q — number of continuum nodes
- Returns:
FWHM in nodes (float)
- Example:
>>> import spm1d >>> print( round( spm1d.rng.lkc2fwhm( 5, 101 ), 3 ) ) 33.302
Generator classes#
- class ANOVA[source]#
Random dataset generator for n-way ANOVA designs.
- Parameters:
nlevels — number of levels of each factor such as
(2, 3)rm — repeated-measures factors as labels (
'AB') or indices.None(default) means all factors and''means none.nsubj — subjects per between-subject group or observations per cell (between-subject designs). A scalar gives a balanced design. A sequence gives unequal sample sizes.
nrep — observations per subject per repeated-measures cell
Q — number of continuum nodes. 1 (default) gives 0D data
fwhm / lkc — 1D smoothness as full-width at half-maximum or Lipschitz-Killing curvature (specify exactly one)
mu — true cell means as a scalar, an array shaped like nlevels or (for 1D data) an array shaped
nlevels + (Q,)sd — error standard deviation as a scalar or as an array shaped like nlevels for unequal group variance
cov — explicit covariance matrix over the repeated-measures cells
cov_model —
'iid','cs','ar1'or'epsilon'rho — correlation for
'cs'and'ar1'eps — target Greenhouse-Geisser epsilon for
'epsilon'ncomp — number of vector components (default 1)
comp_cov_model / comp_rho / comp_eps / comp_cov — covariance between components (same values as cov_model)
subject_sd — standard deviation of the subject random effect
seed — seed for reproducible output
- Example:
>>> g = rng.ANOVA((2, 3), rm='B', nsubj=8, mu=[[0, 0, 1], [0, 0, 1]], sd=1) >>> data = g.random() >>> y, A, B, SUBJ = data.astuple()
- design#
Design object (
spm1d.rng.Design).
- Q#
Number of domain nodes (1 for 0D data).
- fwhm#
Field smoothness as full width at half maximum (
fwhm) and Lipschitz-Killing curvature (lkc). None for 0D data.
- lkc#
Field smoothness as full width at half maximum (
fwhm) and Lipschitz-Killing curvature (lkc). None for 0D data.
- mu#
True cell means as an
(ncells, Q)array.
- sd#
Error standard deviation of each cell as an
(ncells,)array.
- subject_sd#
Standard deviation of the subject random effect.
- cov_within#
Covariance over the repeated-measures cells as an
(nrmcells, nrmcells)array.
- I#
Number of vector components (1 for univariate data).
- cov_comp#
Covariance between vector components as an
(I, I)array if present, otherwise None.
- ncov#
Number of covariates (0 for an ANOVA design).
- slopes#
True covariate slopes as an
(ncov, Q)array.
- covariate_kind#
Covariate value distribution (
"normal","uniform"or"given").
- covariate_input#
Covariate values given at construction if present, otherwise None.
- seed#
Random seed given at construction if present, otherwise None.
- cov#
Full covariance over observations as a
(J, J)array.
- property epsilon#
Greenhouse-Geisser epsilon of the within-subject covariance.
- class ANCOVA[source]#
Random dataset generator for ANCOVA designs.
- Parameters:
In addition to the ANOVA parameters:
ncov — number of continuous covariates (default 1)
slopes — true slope of each covariate as a scalar, an (ncov,) array or an (ncov,Q) array for 1D data
covariate_kind —
'normal'or'uniform'covariate_values — explicit (J,ncov) covariate values
- Example:
>>> g = rng.ANCOVA((2,), nsubj=12, rm='', ncov=1, slopes=0.5, mu=[0, 1]) >>> y, A, x = g.random().astuple()
- property epsilon#
Greenhouse-Geisser epsilon of the within-subject covariance.
- random()#
Generate one random dataset.
- Returns:
A Dataset instance
- Example:
>>> import spm1d >>> g = spm1d.rng.ANOVA( (2, 3), rm='B', nsubj=8, Q=101, fwhm=20, seed=0 ) >>> y, A, B, SUBJ = g.random().astuple() >>> print( y.shape ) (48, 101)
- random_many(n)#
Generate n datasets.
- Parameters:
n — number of datasets
- Returns:
List of n Dataset instances
- Example:
>>> import spm1d >>> g = spm1d.rng.ANOVA( (2, 3), rm='B', nsubj=8, Q=101, fwhm=20, seed=0 ) >>> datasets = g.random_many( 10 ) >>> print( len( datasets ) ) 10
- design#
Design object (
spm1d.rng.Design).
- Q#
Number of domain nodes (1 for 0D data).
- fwhm#
Field smoothness as full width at half maximum (
fwhm) and Lipschitz-Killing curvature (lkc). None for 0D data.
- lkc#
Field smoothness as full width at half maximum (
fwhm) and Lipschitz-Killing curvature (lkc). None for 0D data.
- mu#
True cell means as an
(ncells, Q)array.
- sd#
Error standard deviation of each cell as an
(ncells,)array.
- subject_sd#
Standard deviation of the subject random effect.
- cov_within#
Covariance over the repeated-measures cells as an
(nrmcells, nrmcells)array.
- I#
Number of vector components (1 for univariate data).
- cov_comp#
Covariance between vector components as an
(I, I)array if present, otherwise None.
- ncov#
Number of covariates (0 for an ANOVA design).
- slopes#
True covariate slopes as an
(ncov, Q)array.
- covariate_kind#
Covariate value distribution (
"normal","uniform"or"given").
- covariate_input#
Covariate values given at construction if present, otherwise None.
- seed#
Random seed given at construction if present, otherwise None.
- cov#
Full covariance over observations as a
(J, J)array.
- class Regression[source]#
Random dataset generator for regression with continuous predictors only.
- Parameters:
J — number of observations
ncov — number of predictors (default 1)
slopes — true slope of each predictor
ANOVA parameters controlling data type, smoothness and error
- Example:
>>> g = rng.Regression(J=20, slopes=0.8, Q=101, fwhm=20) >>> y, x = g.random().astuple()
- property epsilon#
Greenhouse-Geisser epsilon of the within-subject covariance.
- random()#
Generate one random dataset.
- Returns:
A Dataset instance
- Example:
>>> import spm1d >>> g = spm1d.rng.ANOVA( (2, 3), rm='B', nsubj=8, Q=101, fwhm=20, seed=0 ) >>> y, A, B, SUBJ = g.random().astuple() >>> print( y.shape ) (48, 101)
- random_many(n)#
Generate n datasets.
- Parameters:
n — number of datasets
- Returns:
List of n Dataset instances
- Example:
>>> import spm1d >>> g = spm1d.rng.ANOVA( (2, 3), rm='B', nsubj=8, Q=101, fwhm=20, seed=0 ) >>> datasets = g.random_many( 10 ) >>> print( len( datasets ) ) 10
- design#
Design object (
spm1d.rng.Design).
- Q#
Number of domain nodes (1 for 0D data).
- fwhm#
Field smoothness as full width at half maximum (
fwhm) and Lipschitz-Killing curvature (lkc). None for 0D data.
- lkc#
Field smoothness as full width at half maximum (
fwhm) and Lipschitz-Killing curvature (lkc). None for 0D data.
- mu#
True cell means as an
(ncells, Q)array.
- sd#
Error standard deviation of each cell as an
(ncells,)array.
- subject_sd#
Standard deviation of the subject random effect.
- cov_within#
Covariance over the repeated-measures cells as an
(nrmcells, nrmcells)array.
- I#
Number of vector components (1 for univariate data).
- cov_comp#
Covariance between vector components as an
(I, I)array if present, otherwise None.
- ncov#
Number of covariates (0 for an ANOVA design).
- slopes#
True covariate slopes as an
(ncov, Q)array.
- covariate_kind#
Covariate value distribution (
"normal","uniform"or"given").
- covariate_input#
Covariate values given at construction if present, otherwise None.
- seed#
Random seed given at construction if present, otherwise None.
- cov#
Full covariance over observations as a
(J, J)array.
- class TTEST[source]#
One-sample t test (Hotelling’s T2 if ncomp > 1).
- random()[source]#
Generate one random dataset.
- Returns:
A Dataset instance
- Example:
>>> import spm1d >>> g = spm1d.rng.TTEST( nsubj=8, Q=101, fwhm=20, seed=0 ) >>> y, = g.random().astuple() >>> print( y.shape ) (8, 101)
- property epsilon#
Greenhouse-Geisser epsilon of the within-subject covariance.
- random_many(n)#
Generate n datasets.
- Parameters:
n — number of datasets
- Returns:
List of n Dataset instances
- Example:
>>> import spm1d >>> g = spm1d.rng.ANOVA( (2, 3), rm='B', nsubj=8, Q=101, fwhm=20, seed=0 ) >>> datasets = g.random_many( 10 ) >>> print( len( datasets ) ) 10
- design#
Design object (
spm1d.rng.Design).
- Q#
Number of domain nodes (1 for 0D data).
- fwhm#
Field smoothness as full width at half maximum (
fwhm) and Lipschitz-Killing curvature (lkc). None for 0D data.
- lkc#
Field smoothness as full width at half maximum (
fwhm) and Lipschitz-Killing curvature (lkc). None for 0D data.
- mu#
True cell means as an
(ncells, Q)array.
- sd#
Error standard deviation of each cell as an
(ncells,)array.
- subject_sd#
Standard deviation of the subject random effect.
- cov_within#
Covariance over the repeated-measures cells as an
(nrmcells, nrmcells)array.
- I#
Number of vector components (1 for univariate data).
- cov_comp#
Covariance between vector components as an
(I, I)array if present, otherwise None.
- ncov#
Number of covariates (0 for an ANOVA design).
- slopes#
True covariate slopes as an
(ncov, Q)array.
- covariate_kind#
Covariate value distribution (
"normal","uniform"or"given").
- covariate_input#
Covariate values given at construction if present, otherwise None.
- seed#
Random seed given at construction if present, otherwise None.
- cov#
Full covariance over observations as a
(J, J)array.
- class TTEST_PAIRED[source]#
Paired t test (Hotelling’s T2 if ncomp > 1).
- random()[source]#
Generate one random dataset.
- Returns:
A Dataset instance
- Example:
>>> import spm1d >>> g = spm1d.rng.TTEST_PAIRED( nsubj=8, Q=101, fwhm=20, seed=0 ) >>> y0, y1 = g.random().astuple() >>> print( y0.shape, y1.shape ) (8, 101) (8, 101)
- property epsilon#
Greenhouse-Geisser epsilon of the within-subject covariance.
- random_many(n)#
Generate n datasets.
- Parameters:
n — number of datasets
- Returns:
List of n Dataset instances
- Example:
>>> import spm1d >>> g = spm1d.rng.ANOVA( (2, 3), rm='B', nsubj=8, Q=101, fwhm=20, seed=0 ) >>> datasets = g.random_many( 10 ) >>> print( len( datasets ) ) 10
- design#
Design object (
spm1d.rng.Design).
- Q#
Number of domain nodes (1 for 0D data).
- fwhm#
Field smoothness as full width at half maximum (
fwhm) and Lipschitz-Killing curvature (lkc). None for 0D data.
- lkc#
Field smoothness as full width at half maximum (
fwhm) and Lipschitz-Killing curvature (lkc). None for 0D data.
- mu#
True cell means as an
(ncells, Q)array.
- sd#
Error standard deviation of each cell as an
(ncells,)array.
- subject_sd#
Standard deviation of the subject random effect.
- cov_within#
Covariance over the repeated-measures cells as an
(nrmcells, nrmcells)array.
- I#
Number of vector components (1 for univariate data).
- cov_comp#
Covariance between vector components as an
(I, I)array if present, otherwise None.
- ncov#
Number of covariates (0 for an ANOVA design).
- slopes#
True covariate slopes as an
(ncov, Q)array.
- covariate_kind#
Covariate value distribution (
"normal","uniform"or"given").
- covariate_input#
Covariate values given at construction if present, otherwise None.
- seed#
Random seed given at construction if present, otherwise None.
- cov#
Full covariance over observations as a
(J, J)array.
- class TTEST2[source]#
Two-sample t test (Hotelling’s T2 if ncomp > 1).
- random()[source]#
Generate one random dataset.
- Returns:
A Dataset instance
- Example:
>>> import spm1d >>> g = spm1d.rng.TTEST2( nsubj=8, Q=101, fwhm=20, seed=0 ) >>> y0, y1 = g.random().astuple() >>> print( y0.shape, y1.shape ) (8, 101) (8, 101)
- property epsilon#
Greenhouse-Geisser epsilon of the within-subject covariance.
- random_many(n)#
Generate n datasets.
- Parameters:
n — number of datasets
- Returns:
List of n Dataset instances
- Example:
>>> import spm1d >>> g = spm1d.rng.ANOVA( (2, 3), rm='B', nsubj=8, Q=101, fwhm=20, seed=0 ) >>> datasets = g.random_many( 10 ) >>> print( len( datasets ) ) 10
- design#
Design object (
spm1d.rng.Design).
- Q#
Number of domain nodes (1 for 0D data).
- fwhm#
Field smoothness as full width at half maximum (
fwhm) and Lipschitz-Killing curvature (lkc). None for 0D data.
- lkc#
Field smoothness as full width at half maximum (
fwhm) and Lipschitz-Killing curvature (lkc). None for 0D data.
- mu#
True cell means as an
(ncells, Q)array.
- sd#
Error standard deviation of each cell as an
(ncells,)array.
- subject_sd#
Standard deviation of the subject random effect.
- cov_within#
Covariance over the repeated-measures cells as an
(nrmcells, nrmcells)array.
- I#
Number of vector components (1 for univariate data).
- cov_comp#
Covariance between vector components as an
(I, I)array if present, otherwise None.
- ncov#
Number of covariates (0 for an ANOVA design).
- slopes#
True covariate slopes as an
(ncov, Q)array.
- covariate_kind#
Covariate value distribution (
"normal","uniform"or"given").
- covariate_input#
Covariate values given at construction if present, otherwise None.
- seed#
Random seed given at construction if present, otherwise None.
- cov#
Full covariance over observations as a
(J, J)array.
- class ANOVA1[source]#
One-way between-subject ANOVA. nsubj is the number of observations per group.
- property epsilon#
Greenhouse-Geisser epsilon of the within-subject covariance.
- random()#
Generate one random dataset.
- Returns:
A Dataset instance
- Example:
>>> import spm1d >>> g = spm1d.rng.ANOVA( (2, 3), rm='B', nsubj=8, Q=101, fwhm=20, seed=0 ) >>> y, A, B, SUBJ = g.random().astuple() >>> print( y.shape ) (48, 101)
- random_many(n)#
Generate n datasets.
- Parameters:
n — number of datasets
- Returns:
List of n Dataset instances
- Example:
>>> import spm1d >>> g = spm1d.rng.ANOVA( (2, 3), rm='B', nsubj=8, Q=101, fwhm=20, seed=0 ) >>> datasets = g.random_many( 10 ) >>> print( len( datasets ) ) 10
- design#
Design object (
spm1d.rng.Design).
- Q#
Number of domain nodes (1 for 0D data).
- fwhm#
Field smoothness as full width at half maximum (
fwhm) and Lipschitz-Killing curvature (lkc). None for 0D data.
- lkc#
Field smoothness as full width at half maximum (
fwhm) and Lipschitz-Killing curvature (lkc). None for 0D data.
- mu#
True cell means as an
(ncells, Q)array.
- sd#
Error standard deviation of each cell as an
(ncells,)array.
- subject_sd#
Standard deviation of the subject random effect.
- cov_within#
Covariance over the repeated-measures cells as an
(nrmcells, nrmcells)array.
- I#
Number of vector components (1 for univariate data).
- cov_comp#
Covariance between vector components as an
(I, I)array if present, otherwise None.
- ncov#
Number of covariates (0 for an ANOVA design).
- slopes#
True covariate slopes as an
(ncov, Q)array.
- covariate_kind#
Covariate value distribution (
"normal","uniform"or"given").
- covariate_input#
Covariate values given at construction if present, otherwise None.
- seed#
Random seed given at construction if present, otherwise None.
- cov#
Full covariance over observations as a
(J, J)array.
- class ANOVA1RM[source]#
One-way repeated-measures ANOVA. nsubj is the number of subjects.
- property epsilon#
Greenhouse-Geisser epsilon of the within-subject covariance.
- random()#
Generate one random dataset.
- Returns:
A Dataset instance
- Example:
>>> import spm1d >>> g = spm1d.rng.ANOVA( (2, 3), rm='B', nsubj=8, Q=101, fwhm=20, seed=0 ) >>> y, A, B, SUBJ = g.random().astuple() >>> print( y.shape ) (48, 101)
- random_many(n)#
Generate n datasets.
- Parameters:
n — number of datasets
- Returns:
List of n Dataset instances
- Example:
>>> import spm1d >>> g = spm1d.rng.ANOVA( (2, 3), rm='B', nsubj=8, Q=101, fwhm=20, seed=0 ) >>> datasets = g.random_many( 10 ) >>> print( len( datasets ) ) 10
- design#
Design object (
spm1d.rng.Design).
- Q#
Number of domain nodes (1 for 0D data).
- fwhm#
Field smoothness as full width at half maximum (
fwhm) and Lipschitz-Killing curvature (lkc). None for 0D data.
- lkc#
Field smoothness as full width at half maximum (
fwhm) and Lipschitz-Killing curvature (lkc). None for 0D data.
- mu#
True cell means as an
(ncells, Q)array.
- sd#
Error standard deviation of each cell as an
(ncells,)array.
- subject_sd#
Standard deviation of the subject random effect.
- cov_within#
Covariance over the repeated-measures cells as an
(nrmcells, nrmcells)array.
- I#
Number of vector components (1 for univariate data).
- cov_comp#
Covariance between vector components as an
(I, I)array if present, otherwise None.
- ncov#
Number of covariates (0 for an ANOVA design).
- slopes#
True covariate slopes as an
(ncov, Q)array.
- covariate_kind#
Covariate value distribution (
"normal","uniform"or"given").
- covariate_input#
Covariate values given at construction if present, otherwise None.
- seed#
Random seed given at construction if present, otherwise None.
- cov#
Full covariance over observations as a
(J, J)array.
- class ANOVA2[source]#
Two-way between-subject ANOVA. nsubj is the number of observations per cell.
- property epsilon#
Greenhouse-Geisser epsilon of the within-subject covariance.
- random()#
Generate one random dataset.
- Returns:
A Dataset instance
- Example:
>>> import spm1d >>> g = spm1d.rng.ANOVA( (2, 3), rm='B', nsubj=8, Q=101, fwhm=20, seed=0 ) >>> y, A, B, SUBJ = g.random().astuple() >>> print( y.shape ) (48, 101)
- random_many(n)#
Generate n datasets.
- Parameters:
n — number of datasets
- Returns:
List of n Dataset instances
- Example:
>>> import spm1d >>> g = spm1d.rng.ANOVA( (2, 3), rm='B', nsubj=8, Q=101, fwhm=20, seed=0 ) >>> datasets = g.random_many( 10 ) >>> print( len( datasets ) ) 10
- design#
Design object (
spm1d.rng.Design).
- Q#
Number of domain nodes (1 for 0D data).
- fwhm#
Field smoothness as full width at half maximum (
fwhm) and Lipschitz-Killing curvature (lkc). None for 0D data.
- lkc#
Field smoothness as full width at half maximum (
fwhm) and Lipschitz-Killing curvature (lkc). None for 0D data.
- mu#
True cell means as an
(ncells, Q)array.
- sd#
Error standard deviation of each cell as an
(ncells,)array.
- subject_sd#
Standard deviation of the subject random effect.
- cov_within#
Covariance over the repeated-measures cells as an
(nrmcells, nrmcells)array.
- I#
Number of vector components (1 for univariate data).
- cov_comp#
Covariance between vector components as an
(I, I)array if present, otherwise None.
- ncov#
Number of covariates (0 for an ANOVA design).
- slopes#
True covariate slopes as an
(ncov, Q)array.
- covariate_kind#
Covariate value distribution (
"normal","uniform"or"given").
- covariate_input#
Covariate values given at construction if present, otherwise None.
- seed#
Random seed given at construction if present, otherwise None.
- cov#
Full covariance over observations as a
(J, J)array.
- class ANOVA2RM[source]#
Two-way repeated-measures ANOVA (both factors repeated).
- property epsilon#
Greenhouse-Geisser epsilon of the within-subject covariance.
- random()#
Generate one random dataset.
- Returns:
A Dataset instance
- Example:
>>> import spm1d >>> g = spm1d.rng.ANOVA( (2, 3), rm='B', nsubj=8, Q=101, fwhm=20, seed=0 ) >>> y, A, B, SUBJ = g.random().astuple() >>> print( y.shape ) (48, 101)
- random_many(n)#
Generate n datasets.
- Parameters:
n — number of datasets
- Returns:
List of n Dataset instances
- Example:
>>> import spm1d >>> g = spm1d.rng.ANOVA( (2, 3), rm='B', nsubj=8, Q=101, fwhm=20, seed=0 ) >>> datasets = g.random_many( 10 ) >>> print( len( datasets ) ) 10
- design#
Design object (
spm1d.rng.Design).
- Q#
Number of domain nodes (1 for 0D data).
- fwhm#
Field smoothness as full width at half maximum (
fwhm) and Lipschitz-Killing curvature (lkc). None for 0D data.
- lkc#
Field smoothness as full width at half maximum (
fwhm) and Lipschitz-Killing curvature (lkc). None for 0D data.
- mu#
True cell means as an
(ncells, Q)array.
- sd#
Error standard deviation of each cell as an
(ncells,)array.
- subject_sd#
Standard deviation of the subject random effect.
- cov_within#
Covariance over the repeated-measures cells as an
(nrmcells, nrmcells)array.
- I#
Number of vector components (1 for univariate data).
- cov_comp#
Covariance between vector components as an
(I, I)array if present, otherwise None.
- ncov#
Number of covariates (0 for an ANOVA design).
- slopes#
True covariate slopes as an
(ncov, Q)array.
- covariate_kind#
Covariate value distribution (
"normal","uniform"or"given").
- covariate_input#
Covariate values given at construction if present, otherwise None.
- seed#
Random seed given at construction if present, otherwise None.
- cov#
Full covariance over observations as a
(J, J)array.
- class ANOVA2ONERM[source]#
Two-way ANOVA with repeated measures on the second factor (B).
- property epsilon#
Greenhouse-Geisser epsilon of the within-subject covariance.
- random()#
Generate one random dataset.
- Returns:
A Dataset instance
- Example:
>>> import spm1d >>> g = spm1d.rng.ANOVA( (2, 3), rm='B', nsubj=8, Q=101, fwhm=20, seed=0 ) >>> y, A, B, SUBJ = g.random().astuple() >>> print( y.shape ) (48, 101)
- random_many(n)#
Generate n datasets.
- Parameters:
n — number of datasets
- Returns:
List of n Dataset instances
- Example:
>>> import spm1d >>> g = spm1d.rng.ANOVA( (2, 3), rm='B', nsubj=8, Q=101, fwhm=20, seed=0 ) >>> datasets = g.random_many( 10 ) >>> print( len( datasets ) ) 10
- design#
Design object (
spm1d.rng.Design).
- Q#
Number of domain nodes (1 for 0D data).
- fwhm#
Field smoothness as full width at half maximum (
fwhm) and Lipschitz-Killing curvature (lkc). None for 0D data.
- lkc#
Field smoothness as full width at half maximum (
fwhm) and Lipschitz-Killing curvature (lkc). None for 0D data.
- mu#
True cell means as an
(ncells, Q)array.
- sd#
Error standard deviation of each cell as an
(ncells,)array.
- subject_sd#
Standard deviation of the subject random effect.
- cov_within#
Covariance over the repeated-measures cells as an
(nrmcells, nrmcells)array.
- I#
Number of vector components (1 for univariate data).
- cov_comp#
Covariance between vector components as an
(I, I)array if present, otherwise None.
- ncov#
Number of covariates (0 for an ANOVA design).
- slopes#
True covariate slopes as an
(ncov, Q)array.
- covariate_kind#
Covariate value distribution (
"normal","uniform"or"given").
- covariate_input#
Covariate values given at construction if present, otherwise None.
- seed#
Random seed given at construction if present, otherwise None.
- cov#
Full covariance over observations as a
(J, J)array.
- class ANOVA3[source]#
Three-way between-subject ANOVA.
- property epsilon#
Greenhouse-Geisser epsilon of the within-subject covariance.
- random()#
Generate one random dataset.
- Returns:
A Dataset instance
- Example:
>>> import spm1d >>> g = spm1d.rng.ANOVA( (2, 3), rm='B', nsubj=8, Q=101, fwhm=20, seed=0 ) >>> y, A, B, SUBJ = g.random().astuple() >>> print( y.shape ) (48, 101)
- random_many(n)#
Generate n datasets.
- Parameters:
n — number of datasets
- Returns:
List of n Dataset instances
- Example:
>>> import spm1d >>> g = spm1d.rng.ANOVA( (2, 3), rm='B', nsubj=8, Q=101, fwhm=20, seed=0 ) >>> datasets = g.random_many( 10 ) >>> print( len( datasets ) ) 10
- design#
Design object (
spm1d.rng.Design).
- Q#
Number of domain nodes (1 for 0D data).
- fwhm#
Field smoothness as full width at half maximum (
fwhm) and Lipschitz-Killing curvature (lkc). None for 0D data.
- lkc#
Field smoothness as full width at half maximum (
fwhm) and Lipschitz-Killing curvature (lkc). None for 0D data.
- mu#
True cell means as an
(ncells, Q)array.
- sd#
Error standard deviation of each cell as an
(ncells,)array.
- subject_sd#
Standard deviation of the subject random effect.
- cov_within#
Covariance over the repeated-measures cells as an
(nrmcells, nrmcells)array.
- I#
Number of vector components (1 for univariate data).
- cov_comp#
Covariance between vector components as an
(I, I)array if present, otherwise None.
- ncov#
Number of covariates (0 for an ANOVA design).
- slopes#
True covariate slopes as an
(ncov, Q)array.
- covariate_kind#
Covariate value distribution (
"normal","uniform"or"given").
- covariate_input#
Covariate values given at construction if present, otherwise None.
- seed#
Random seed given at construction if present, otherwise None.
- cov#
Full covariance over observations as a
(J, J)array.
- class ANOVA3RM[source]#
Three-way repeated-measures ANOVA (all factors repeated).
- property epsilon#
Greenhouse-Geisser epsilon of the within-subject covariance.
- random()#
Generate one random dataset.
- Returns:
A Dataset instance
- Example:
>>> import spm1d >>> g = spm1d.rng.ANOVA( (2, 3), rm='B', nsubj=8, Q=101, fwhm=20, seed=0 ) >>> y, A, B, SUBJ = g.random().astuple() >>> print( y.shape ) (48, 101)
- random_many(n)#
Generate n datasets.
- Parameters:
n — number of datasets
- Returns:
List of n Dataset instances
- Example:
>>> import spm1d >>> g = spm1d.rng.ANOVA( (2, 3), rm='B', nsubj=8, Q=101, fwhm=20, seed=0 ) >>> datasets = g.random_many( 10 ) >>> print( len( datasets ) ) 10
- design#
Design object (
spm1d.rng.Design).
- Q#
Number of domain nodes (1 for 0D data).
- fwhm#
Field smoothness as full width at half maximum (
fwhm) and Lipschitz-Killing curvature (lkc). None for 0D data.
- lkc#
Field smoothness as full width at half maximum (
fwhm) and Lipschitz-Killing curvature (lkc). None for 0D data.
- mu#
True cell means as an
(ncells, Q)array.
- sd#
Error standard deviation of each cell as an
(ncells,)array.
- subject_sd#
Standard deviation of the subject random effect.
- cov_within#
Covariance over the repeated-measures cells as an
(nrmcells, nrmcells)array.
- I#
Number of vector components (1 for univariate data).
- cov_comp#
Covariance between vector components as an
(I, I)array if present, otherwise None.
- ncov#
Number of covariates (0 for an ANOVA design).
- slopes#
True covariate slopes as an
(ncov, Q)array.
- covariate_kind#
Covariate value distribution (
"normal","uniform"or"given").
- covariate_input#
Covariate values given at construction if present, otherwise None.
- seed#
Random seed given at construction if present, otherwise None.
- cov#
Full covariance over observations as a
(J, J)array.
- class ANOVA3ONERM[source]#
Three-way ANOVA with repeated measures on the third factor (C).
- property epsilon#
Greenhouse-Geisser epsilon of the within-subject covariance.
- random()#
Generate one random dataset.
- Returns:
A Dataset instance
- Example:
>>> import spm1d >>> g = spm1d.rng.ANOVA( (2, 3), rm='B', nsubj=8, Q=101, fwhm=20, seed=0 ) >>> y, A, B, SUBJ = g.random().astuple() >>> print( y.shape ) (48, 101)
- random_many(n)#
Generate n datasets.
- Parameters:
n — number of datasets
- Returns:
List of n Dataset instances
- Example:
>>> import spm1d >>> g = spm1d.rng.ANOVA( (2, 3), rm='B', nsubj=8, Q=101, fwhm=20, seed=0 ) >>> datasets = g.random_many( 10 ) >>> print( len( datasets ) ) 10
- design#
Design object (
spm1d.rng.Design).
- Q#
Number of domain nodes (1 for 0D data).
- fwhm#
Field smoothness as full width at half maximum (
fwhm) and Lipschitz-Killing curvature (lkc). None for 0D data.
- lkc#
Field smoothness as full width at half maximum (
fwhm) and Lipschitz-Killing curvature (lkc). None for 0D data.
- mu#
True cell means as an
(ncells, Q)array.
- sd#
Error standard deviation of each cell as an
(ncells,)array.
- subject_sd#
Standard deviation of the subject random effect.
- cov_within#
Covariance over the repeated-measures cells as an
(nrmcells, nrmcells)array.
- I#
Number of vector components (1 for univariate data).
- cov_comp#
Covariance between vector components as an
(I, I)array if present, otherwise None.
- ncov#
Number of covariates (0 for an ANOVA design).
- slopes#
True covariate slopes as an
(ncov, Q)array.
- covariate_kind#
Covariate value distribution (
"normal","uniform"or"given").
- covariate_input#
Covariate values given at construction if present, otherwise None.
- seed#
Random seed given at construction if present, otherwise None.
- cov#
Full covariance over observations as a
(J, J)array.
- class ANOVA3TWORM[source]#
Three-way ANOVA with repeated measures on the second and third factors (B, C).
- property epsilon#
Greenhouse-Geisser epsilon of the within-subject covariance.
- random()#
Generate one random dataset.
- Returns:
A Dataset instance
- Example:
>>> import spm1d >>> g = spm1d.rng.ANOVA( (2, 3), rm='B', nsubj=8, Q=101, fwhm=20, seed=0 ) >>> y, A, B, SUBJ = g.random().astuple() >>> print( y.shape ) (48, 101)
- random_many(n)#
Generate n datasets.
- Parameters:
n — number of datasets
- Returns:
List of n Dataset instances
- Example:
>>> import spm1d >>> g = spm1d.rng.ANOVA( (2, 3), rm='B', nsubj=8, Q=101, fwhm=20, seed=0 ) >>> datasets = g.random_many( 10 ) >>> print( len( datasets ) ) 10
- design#
Design object (
spm1d.rng.Design).
- Q#
Number of domain nodes (1 for 0D data).
- fwhm#
Field smoothness as full width at half maximum (
fwhm) and Lipschitz-Killing curvature (lkc). None for 0D data.
- lkc#
Field smoothness as full width at half maximum (
fwhm) and Lipschitz-Killing curvature (lkc). None for 0D data.
- mu#
True cell means as an
(ncells, Q)array.
- sd#
Error standard deviation of each cell as an
(ncells,)array.
- subject_sd#
Standard deviation of the subject random effect.
- cov_within#
Covariance over the repeated-measures cells as an
(nrmcells, nrmcells)array.
- I#
Number of vector components (1 for univariate data).
- cov_comp#
Covariance between vector components as an
(I, I)array if present, otherwise None.
- ncov#
Number of covariates (0 for an ANOVA design).
- slopes#
True covariate slopes as an
(ncov, Q)array.
- covariate_kind#
Covariate value distribution (
"normal","uniform"or"given").
- covariate_input#
Covariate values given at construction if present, otherwise None.
- seed#
Random seed given at construction if present, otherwise None.
- cov#
Full covariance over observations as a
(J, J)array.
- CLASSIC#
Generator class of each classic design name, from
'ttest'to'regress'. The functions above are built from it.
- class Dataset[source]#
A generated dataset.
- Attributes:
Y — (J,Q) data array or (J,) data array for 0D data
factors — list of (J,1) discrete factor level vectors
SUBJ — (J,1) subject labels if present, otherwise
NoneX — (J,ncov) covariate values if present, otherwise
Nonedesign — Design used
- Y#
Data as a
(J,Q)array for 1D data or a(J,)array for 0D data ((J,Q,I)or(J,I)for multivariate data).
- factors#
One
(J,)integer level vector per factor.
- SUBJ#
Subject labels as a
(J,)integer array if present, otherwise None.
- X#
Covariate values as a
(J, ncov)array if present, otherwise None.
- design#
spm1d.rng.Designthe dataset was drawn from.
- astuple()[source]#
Data as a tuple ordered for the spm1d.stats call signatures.
- Returns:
(Y, *factors, *covariates, SUBJ)with absent items omitted
- Example:
>>> import spm1d >>> g = spm1d.rng.ANOVA( (2, 3), rm='B', nsubj=8, Q=101, fwhm=20, seed=0 ) >>> y, A, B, SUBJ = g.random().astuple() >>> spmi = spm1d.stats.anova2onerm( y, A, B, SUBJ ).inference( 0.05 )
- class Design[source]#
A balanced experimental design.
- Parameters:
nlevels — number of levels of each discrete factor such as
(2, 3). Use()for regression designs.rm — repeated-measures factors as labels (
'AB') or indices ([0, 1]).None(default) means all factors and''means none.nsubj — subjects per between-subject group (repeated-measures designs) or observations per cell (between-subject designs). A scalar gives a balanced design. A sequence gives unequal sample sizes.
nrep — observations per subject per cell (repeated-measures designs)
labels — factor labels (default:
'A','B', …)
- Attributes:
factors — list of (J,1) integer level vectors
SUBJ — (J,1) integer subject labels if present, otherwise
NoneJ — number of observations
cell — (J,1) index of each observation’s cell (all factors)
rmcell — (J,1) index of each observation’s repeated-measures cell
- nlevels#
Number of levels of each factor.
- nfactors#
Number of factors.
- labels#
Factor labels (
"A","B", …).
- rm_labels#
Labels of the repeated-measures factors.
- btwn_labels#
Labels of the between-subjects factors.
- nsubj#
Number of subjects (or observations) in each between-subjects group.
- nrep#
Observations per subject per repeated-measures cell.
- factors#
Factor level vectors (one
(J,)integer array per factor) and subject labels ((J,)array if present, otherwise None).
- SUBJ#
Factor level vectors (one
(J,)integer array per factor) and subject labels ((J,)array if present, otherwise None).
- J#
Number of observations.
- property balanced#
True if every between-subject group has the same sample size.
- property cell#
Index of each observation’s cell in the full factorial design.
- property is_rm#
True if the design contains at least one repeated-measures factor.
- property ncells#
Number of cells of the full factorial design.
- property nrmcells#
Number of repeated-measures cells (1 if there are none).
- property nsubjects#
Number of distinct subjects (0 for a between-subjects design).
- replicate()[source]#
Index of each observation within its subject and repeated-measures cell.
- Returns:
(J,) integer array (0 for the first observation, 1 for the second and so on)
- Example:
>>> import spm1d >>> design = spm1d.rng.Design( (2, 3), rm='A', nsubj=4, nrep=2 ) >>> print( design.replicate()[:6] ) [0 1 0 1 0 1]
- property rm_nlevels#
Number of levels of each repeated-measures factor.
- property rmcell#
Index of each observation’s repeated-measures cell.