Random functions

rand_bool(p) Returns True with probability p (RNG).
rand_norm([mean, sd]) Samples from a normal distribution with mean mean and standard deviation sd (RNG).
rand_pois(lamb) Samples from a Poisson distribution with rate parameter lamb (RNG).
rand_unif(min, max) Returns a random floating-point number uniformly drawn from the interval [min, max].
hail.expr.functions.rand_bool(p) → hail.expr.expressions.typed_expressions.BooleanExpression[source]

Returns True with probability p (RNG).

Examples

>>> hl.rand_bool(0.5).value
True
>>> hl.rand_bool(0.5).value
False

Warning

This function is non-deterministic, meaning that successive runs of the same pipeline including RNG expressions may return different results. This is a known bug.

Parameters:p (float or Expression of type tfloat64) – Probability between 0 and 1.
Returns:BooleanExpression
hail.expr.functions.rand_norm(mean=0, sd=1) → hail.expr.expressions.typed_expressions.Float64Expression[source]

Samples from a normal distribution with mean mean and standard deviation sd (RNG).

Examples

>>> hl.rand_norm().value
1.5388475315213386
>>> hl.rand_norm().value
-0.3006188509144124

Warning

This function is non-deterministic, meaning that successive runs of the same pipeline including RNG expressions may return different results. This is a known bug.

Parameters:
Returns:

Expression of type tfloat64

hail.expr.functions.rand_pois(lamb) → hail.expr.expressions.typed_expressions.Float64Expression[source]

Samples from a Poisson distribution with rate parameter lamb (RNG).

Examples

>>> hl.rand_pois(1).value
2.0
>>> hl.rand_pois(1).value
3.0

Warning

This function is non-deterministic, meaning that successive runs of the same pipeline including RNG expressions may return different results. This is a known bug.

Parameters:lamb (float or Expression of type tfloat64) – Rate parameter for Poisson distribution.
Returns:Expression of type tfloat64
hail.expr.functions.rand_unif(min, max) → hail.expr.expressions.typed_expressions.Float64Expression[source]

Returns a random floating-point number uniformly drawn from the interval [min, max].

Examples

>>> hl.rand_unif(0, 1).value
0.7983073825816226
>>> hl.rand_unif(0, 1).value
0.5161799497741769

Warning

This function is non-deterministic, meaning that successive runs of the same pipeline including RNG expressions may return different results. This is a known bug.

Parameters:
Returns:

Expression of type tfloat64