DiscreteVariable.draw

DiscreteVariable.draw(x)

Draw a random float value from the x-th interval of the variable (only for pyagrum.DiscretizedVariable).

Parameters:

x (int) – the index of the interval from which to draw

Returns:

a random value drawn uniformly from the x-th interval

Return type:

float

Raises:

Example

import pyagrum as gum

gum.initRandom(42)
v = gum.fastVariable("x[0:10:5]")  # a DiscretizedVariable with intervals of width 2
x = v.draw(1)  # a random value in the interval [2;4[
2 <= x < 4
# True

Used by

DiscreteVariable, IntegerVariable, LabelizedVariable, NumericalDiscreteVariable, RangeVariable

Inheritance diagram of pyagrum.DiscreteVariable, pyagrum.IntegerVariable, pyagrum.LabelizedVariable, pyagrum.NumericalDiscreteVariable, pyagrum.RangeVariable

Overridden in

DiscretizedVariable.draw