|
If you want to have an uniform discrete distribution in [10, 20[ you can do:
X = ot.UserDefined(list(map(lambda x: [x], range(10,20))))
In [10]: print(X.getSample(10))
[ v0 ] 0 : [ 14 ] 1 : [ 19 ] 2 : [ 10 ] 3 : [ 14 ] 4 : [ 17 ] 5 : [ 17 ] 6 : [ 16 ] 7 : [ 18 ] 8 : [ 15 ] 9 : [ 13 ] De : [email protected] <[email protected]> de la part de roy <[email protected]>
Envoyé : mercredi 8 novembre 2017 14:14:04 À : users Objet : [ot-users] Discrete distribution Hi everyone,
I was looking at a way to have discrete distribution.
From the doc there is no discrete distribution (or I missed it) so I wanted to use scipy’s distributions
and wrap them with ot.SciPyDistribution. But with randint I got this issue :
>>> ot.SciPyDistribution(randint)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/roy/Applications/miniconda3/envs/batman3/lib/python3.6/site-packages/openturns/model_copula.py", line 3047, in __init__
raise TypeError('Argument is not a scipy distribution')
TypeError: Argument is not a scipy distribution
I tried commenting the raise and it seems to work as I expected. But I suppose the raise is here for a reason.
Until then I am using this:
from scipy.stats import randint
import openturns as ot
rv = randint(10, 20)
points = ot.Sample(10000, 1)
for i in range(10000):
points[i] = (rv.rvs(),)
disc_dist = ot.UserDefined(points)
Thanks.
Sincerely,
Pamphile ROY
Chercheur doctorant en Quantification d’Incertitudes CERFACS - Toulouse (31) - France +33 (0) 5 61 19 31 57 +33 (0) 7 86 43 24 22 |
_______________________________________________ OpenTURNS users mailing list [email protected] http://openturns.org/mailman/listinfo/users
