-
Notifications
You must be signed in to change notification settings - Fork 1
Variate Generation
The random variable class contains a procedure designed to produce random variates from a given distribution. For ad-hoc random variables, the default is to produce random variates numerically using the Newton-Raphson method. When possible, efficient variate generation algorithms are implemented for special distribution types. If a distribution has an inverse CDF that can be represented explicitly, variates are generated by substituting random percentiles into the inverse CDF. Distributions with inverse CDFs that cannot be represented explicity use an efficient numerical technique suitable for that distribution type. For instance, random variates from the normal distribution are created using the Box-Muller Transformation method.
X.variate(n=1,s=None,sensitivity=None,method='newton-raphson')
-
n (default: 1): specifies the number of random variates to generatre
-
s (default: None): specifies a percentile. If not specified, the procedure will return a variate at a random percentile
-
sensitivity (default: None): the convergence condition for the Newton-Raphson method. If not specified, the procedure will set the convergence conditions at .1% of the mean of the random variable
-
method (default: 'newton-raphson'): specifies the method used to produce random variates. For ad-hoc random variables, the default is to use the Newton-Raphson method. For special random variate types, the default is to use an efficient numerical method specific to that distribution type. Users can generate variates using the inverse CDF method by specifying
method='inverse'
In [26]: X=TriangularRV(2,4,10)
In [27]: X.variate(n=5)
Out[27]:
[3.86974895785312, 6.36419237887348, 6.73255466475721, 7.90509709717614, 8.11856896586658]
In [28]: X.variate(n=5,method='inverse')
Out[28]:
[6.7145549265816, 3.57926668054082, 3.12549970731869, 3.46938140549286, 2.75968525131856]
In [29]: # Compute the median
In [30]: X.variate(s=.5,method='inverse')
Out[30]: [4.56568245337933]