Commit f0f4e5ea authored by Georgios Dagkakis's avatar Georgios Dagkakis

Logistic distribution not to allow negative numbers

parent 2293a2bd
...@@ -67,10 +67,14 @@ class RandomNumberGenerator(object): ...@@ -67,10 +67,14 @@ class RandomNumberGenerator(object):
elif(self.distributionType=="Logistic"): #if the distribution is Logistic elif(self.distributionType=="Logistic"): #if the distribution is Logistic
# XXX from http://stackoverflow.com/questions/3955877/generating-samples-from-the-logistic-distribution # XXX from http://stackoverflow.com/questions/3955877/generating-samples-from-the-logistic-distribution
# to check # to check
from random import random
import math import math
x = random() while 1:
return self.location + self.scale * math.log(x / (1-x)) x = G.Rnd.random()
number=self.location + self.scale * math.log(x / (1-x))
if number>0:
return number
else:
continue
elif(self.distributionType=="Geometric"): #if the distribution is Geometric elif(self.distributionType=="Geometric"): #if the distribution is Geometric
return 1 return 1
elif(self.distributionType=="Lognormal"): #if the distribution is Lognormal elif(self.distributionType=="Lognormal"): #if the distribution is Lognormal
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment