Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
dream
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
dream
Commits
f0f4e5ea
Commit
f0f4e5ea
authored
Oct 22, 2014
by
Georgios Dagkakis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Logistic distribution not to allow negative numbers
parent
2293a2bd
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
3 deletions
+7
-3
dream/simulation/RandomNumberGenerator.py
dream/simulation/RandomNumberGenerator.py
+7
-3
No files found.
dream/simulation/RandomNumberGenerator.py
View file @
f0f4e5ea
...
...
@@ -67,10 +67,14 @@ class RandomNumberGenerator(object):
elif
(
self
.
distributionType
==
"Logistic"
):
#if the distribution is Logistic
# XXX from http://stackoverflow.com/questions/3955877/generating-samples-from-the-logistic-distribution
# to check
from
random
import
random
import
math
x
=
random
()
return
self
.
location
+
self
.
scale
*
math
.
log
(
x
/
(
1
-
x
))
while
1
:
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
return
1
elif
(
self
.
distributionType
==
"Lognormal"
):
#if the distribution is Lognormal
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment