Random sampler

GGPSampler(lik, mean, cov)

Sample from a Generalised Gaussian Process.

GPSampler(mean, cov)

Sample from a Gaussian Process.

glimix_core.random.bernoulli_sample(offset, G, heritability=0.5, causal_variants=None, causal_variance=0, random_state=None)[source]

Bernoulli likelihood sampling.

Sample according to

\[\mathbf y \sim \prod_{i=1}^n \text{Bernoulli}(\mu_i = \text{logit}(z_i)) \mathcal N(~ o \mathbf 1 + \mathbf a^\intercal \boldsymbol\alpha; ~ (h^2 - v_c)\mathrm G^\intercal\mathrm G + (1-h^2-v_c)\mathrm I ~)\]

using the canonical Logit link function to define the conditional Bernoulli mean \(\mu_i\).

The causal \(\mathbf a\) covariates and the corresponding effect-sizes are randomly draw according to the following idea. The causal_variants, if given, are first mean-zero and std-one normalized and then having its elements divided by the squared-root the the number of variances:

causal_variants = _stdnorm(causal_variants, axis=0)
causal_variants /= sqrt(causal_variants.shape[1])

The causal effect-sizes \(\boldsymbol\alpha\) are draw from \(\{-1, +1\}\) and subsequently normalized for mean-zero and std-one””

Parameters

random_state (random_state) – Set the initial random state.

Example

>>> from glimix_core.random import bernoulli_sample
>>> from numpy.random import RandomState
>>> offset = 5
>>> G = [[1, -1], [2, 1]]
>>> bernoulli_sample(offset, G, random_state=RandomState(0))
array([1., 1.])
glimix_core.random.binomial_sample(ntrials, offset, G, heritability=0.5, causal_variants=None, causal_variance=0, random_state=None)[source]

Binomial likelihood sampling.

Parameters

random_state (random_state) – Set the initial random state.

Example

>>> from glimix_core.random import binomial_sample
>>> from numpy.random import RandomState
>>> ntrials = [5, 15]
>>> offset = 0.5
>>> G = [[1, -1], [2, 1]]
>>> binomial_sample(ntrials, offset, G, random_state=RandomState(0))
array([ 2., 14.])
glimix_core.random.poisson_sample(offset, G, heritability=0.5, causal_variants=None, causal_variance=0, random_state=None)[source]

Poisson likelihood sampling.

Parameters

random_state (random_state) – Set the initial random state.

Example

>>> from glimix_core.random import poisson_sample
>>> from numpy.random import RandomState
>>> offset = -0.5
>>> G = [[0.5, -1], [2, 1]]
>>> poisson_sample(offset, G, random_state=RandomState(0))
array([0, 6])