RandomNumberGenerator¶
RandomNumberGenerator is used for generating the individual data points. It supports a wide variety of configurations, which we describe here.
manpy.simulation.RandomNumberGenerator.py¶
Created on 14 Feb 2013
@author: George
- class manpy.simulation.RandomNumberGenerator.RandomNumberGenerator(obj, distribution)[source]¶
Bases:
objectholds methods for generations of numbers from different distributions
- Parameters:
obj – The object that uses RandomNumberGenerator. Only used internally for logging in case of exceptions.
distribution – Dictionary describing the probability distribution from which the random number should be drawn. See Docs for more details.
Configuring the distribution¶
The configuration of the RNG’s internal distribution is usually done via several parameters, e.g. of Feature, Machine or Source. As of now, the distribution is described using dictionaries. There exist plans to improve this mechanism, but we don’t have a concrete roadmap.
Generally speaking, the config dictionary describes the distribution name and its parameters. It always has the following format:
distribution = {"DistributionName": {"Parameter1": value1,
"Parameter2": value2,
...
}
}
When configuring the underlying probability distribution of a feature, you add such a dictionary as a value to “Feature”.
distribution = {"Feature": {"DistributionName": {"Parameter1": value1,
"Parameter2": value2,
...
}
}
}
The following probability distributions and parameters exist:
Distribution |
Parameters |
|---|---|
Fixed |
mean: specifies the value |
Normal |
mean and stdev |
Exp |
mean |
Gamma |
alpha/shape, beta/rate |
Logistic |
location, scale |
Erlang |
alpha/shape, beta/rate |
Lognormal |
mean, stdev |
Weibull |
shape |
Cauchy |
location, scale |
Triangular |
min, max, mean |
Categorical |
See tutorial below |
General Params |
min: minimum output value max: maximum output value |
Besides of numbers, RandomNumberGenerator can also return categorical values, which can be useful in industrial settings. To use this functionality, you need to pass “Categorical” as distribution name. In the parameter dictionary, you specify the probabilities of the individual categorical feature values:
distribution = {"Feature": {"Categorical": {"A": 0.2,
"B": 0.7,
"C": 0.1
}
}
}