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:
NotImplementedError – if the variable is not a
pyagrum.DiscretizedVariablepyagrum.OutOfBounds – if x is not a valid interval index
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

Overridden in