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
2d76d42e
Commit
2d76d42e
authored
Nov 05, 2014
by
Georgios Dagkakis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
RandomNumberGenerator gamma distribution
parent
4af6bc74
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
2 deletions
+9
-2
dream/simulation/RandomNumberGenerator.py
dream/simulation/RandomNumberGenerator.py
+9
-2
No files found.
dream/simulation/RandomNumberGenerator.py
View file @
2d76d42e
...
...
@@ -30,7 +30,7 @@ import math
class
RandomNumberGenerator
(
object
):
def
__init__
(
self
,
obj
,
distributionType
,
mean
=
0
,
stdev
=
0
,
min
=
0
,
max
=
0
,
alpha
=
0
,
beta
=
0
,
logmean
=
0
,
logsd
=
0
,
probability
=
0
,
shape
=
0
,
scale
=
0
,
location
=
0
):
logmean
=
0
,
logsd
=
0
,
probability
=
0
,
shape
=
0
,
scale
=
0
,
location
=
0
,
rate
=
0
,
**
kw
):
self
.
distributionType
=
distributionType
self
.
mean
=
float
(
mean
or
0
)
self
.
stdev
=
float
(
stdev
or
0
)
...
...
@@ -44,6 +44,7 @@ class RandomNumberGenerator(object):
self
.
shape
=
float
(
shape
or
0
)
self
.
scale
=
float
(
scale
or
0
)
self
.
location
=
float
(
location
or
0
)
self
.
rate
=
float
(
rate
or
0
)
self
.
obj
=
obj
def
generateNumber
(
self
):
...
...
@@ -63,7 +64,13 @@ class RandomNumberGenerator(object):
continue
else
:
#if the number is in the limits stop the process
return
number
elif
self
.
distributionType
==
"Erlang"
:
#if the distribution is erlang
elif
self
.
distributionType
==
"Gamma"
or
self
.
distributionType
==
"Erlang"
:
#if the distribution is gamma or erlang
# in case shape is given instead of alpha
if
not
self
.
alpha
:
self
.
alpha
=
self
.
shape
# in case rate is given instead of beta
if
not
self
.
beta
:
self
.
beta
=
1
/
float
(
self
.
rate
)
return
G
.
Rnd
.
gammavariate
(
self
.
alpha
,
self
.
beta
)
elif
(
self
.
distributionType
==
"Logistic"
):
#if the distribution is Logistic
# XXX from http://stackoverflow.com/questions/3955877/generating-samples-from-the-logistic-distribution
...
...
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