simple-random 0.9.0 → 0.9.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +16 -3
- data/VERSION +1 -1
- data/lib/simple-random.rb +4 -3
- data/simple-random.gemspec +15 -22
- metadata +34 -57
- data/.gitignore +0 -21
data/README.rdoc
CHANGED
@@ -1,9 +1,22 @@
|
|
1
1
|
= simple-random
|
2
2
|
|
3
|
-
|
3
|
+
Generate random numbers sampled from the following distributions:
|
4
|
+
|
5
|
+
* Beta
|
6
|
+
* Cauchy
|
7
|
+
* Chi square
|
8
|
+
* Exponential
|
9
|
+
* Inverse gamma
|
10
|
+
* Laplace (double exponential)
|
11
|
+
* Normal
|
12
|
+
* Student t
|
13
|
+
* Uniform
|
14
|
+
* Weibull
|
15
|
+
|
16
|
+
Based on John D. Cook's SimpleRNG[http://www.codeproject.com/KB/recipes/SimpleRNG.aspx] C# library.
|
4
17
|
|
5
18
|
== Note on Patches/Pull Requests
|
6
|
-
|
19
|
+
|
7
20
|
* Fork the project.
|
8
21
|
* Make your feature addition or bug fix.
|
9
22
|
* Add tests for it. This is important so I don't break it in a
|
@@ -14,4 +27,4 @@ Description goes here.
|
|
14
27
|
|
15
28
|
== Copyright
|
16
29
|
|
17
|
-
|
30
|
+
Distributed under the Code Project Open License, which is similar to MIT or BSD. See LICENSE for full details (don't just take my word for it that it's similar to those licenses).
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.9.
|
1
|
+
0.9.2
|
data/lib/simple-random.rb
CHANGED
@@ -11,11 +11,11 @@ class SimpleRandom
|
|
11
11
|
elsif args.first.is_a?(Numeric)
|
12
12
|
@m_w = args.first.to_i if args.first.to_i != 0
|
13
13
|
elsif args.first.is_a?(Time)
|
14
|
-
x = args.first.to_i
|
14
|
+
x = (args.first.to_f * 1000000).to_i
|
15
15
|
@m_w = x >> 16
|
16
16
|
@m_z = x % 4294967296 # 2 ** 32
|
17
17
|
else
|
18
|
-
x = Time.now.to_i
|
18
|
+
x = (Time.now.to_f * 1000000).to_i
|
19
19
|
@m_w = x >> 16
|
20
20
|
@m_z = x % 4294967296 # 2 ** 32
|
21
21
|
end
|
@@ -80,6 +80,7 @@ class SimpleRandom
|
|
80
80
|
end
|
81
81
|
|
82
82
|
def beta(a, b)
|
83
|
+
raise "Alpha and beta parameters must be positive. Received a = #{a} and b = #{b}." unless a > 0 && b > 0
|
83
84
|
u = gamma(a, 1)
|
84
85
|
v = gamma(b, 1)
|
85
86
|
u / (u + v)
|
@@ -184,4 +185,4 @@ class SimpleRandom
|
|
184
185
|
|
185
186
|
ga
|
186
187
|
end
|
187
|
-
end
|
188
|
+
end
|
data/simple-random.gemspec
CHANGED
@@ -1,45 +1,38 @@
|
|
1
1
|
# Generated by jeweler
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{simple-random}
|
8
|
-
s.version = "0.9.
|
8
|
+
s.version = "0.9.2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
-
s.authors = [
|
12
|
-
s.date = %q{
|
11
|
+
s.authors = [%q{John D. Cook}, %q{Jason Adams}]
|
12
|
+
s.date = %q{2011-09-06}
|
13
13
|
s.description = %q{Simple Random Number Generator including Beta, Cauchy, Chi square, Exponential, Gamma, Inverse Gamma, Laplace (double exponential), Normal, Student t, Uniform, and Weibull. Ported from John D. Cook's C# Code.}
|
14
14
|
s.email = %q{jasonmadams@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
16
16
|
"LICENSE",
|
17
|
-
|
17
|
+
"README.rdoc"
|
18
18
|
]
|
19
19
|
s.files = [
|
20
20
|
".document",
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
"test/test_simple_random.rb"
|
21
|
+
"LICENSE",
|
22
|
+
"README.rdoc",
|
23
|
+
"Rakefile",
|
24
|
+
"VERSION",
|
25
|
+
"lib/simple-random.rb",
|
26
|
+
"simple-random.gemspec",
|
27
|
+
"test/helper.rb",
|
28
|
+
"test/test_simple_random.rb"
|
30
29
|
]
|
31
30
|
s.homepage = %q{http://github.com/ealdent/simple-random}
|
32
|
-
s.
|
33
|
-
s.
|
34
|
-
s.rubygems_version = %q{1.3.7}
|
31
|
+
s.require_paths = [%q{lib}]
|
32
|
+
s.rubygems_version = %q{1.8.7}
|
35
33
|
s.summary = %q{Simple Random Number Generator}
|
36
|
-
s.test_files = [
|
37
|
-
"test/helper.rb",
|
38
|
-
"test/test_simple_random.rb"
|
39
|
-
]
|
40
34
|
|
41
35
|
if s.respond_to? :specification_version then
|
42
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
43
36
|
s.specification_version = 3
|
44
37
|
|
45
38
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
metadata
CHANGED
@@ -1,50 +1,39 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: simple-random
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 9
|
9
|
-
- 0
|
10
|
-
version: 0.9.0
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.9.2
|
5
|
+
prerelease:
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- John D. Cook
|
14
9
|
- Jason Adams
|
15
10
|
autorequire:
|
16
11
|
bindir: bin
|
17
12
|
cert_chain: []
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
dependencies:
|
22
|
-
- !ruby/object:Gem::Dependency
|
13
|
+
date: 2011-09-06 00:00:00.000000000Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
23
16
|
name: shoulda
|
24
|
-
|
25
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
17
|
+
requirement: &2160292400 !ruby/object:Gem::Requirement
|
26
18
|
none: false
|
27
|
-
requirements:
|
28
|
-
- -
|
29
|
-
- !ruby/object:Gem::Version
|
30
|
-
|
31
|
-
segments:
|
32
|
-
- 0
|
33
|
-
version: "0"
|
19
|
+
requirements:
|
20
|
+
- - ! '>='
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '0'
|
34
23
|
type: :development
|
35
|
-
|
36
|
-
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: *2160292400
|
26
|
+
description: Simple Random Number Generator including Beta, Cauchy, Chi square, Exponential,
|
27
|
+
Gamma, Inverse Gamma, Laplace (double exponential), Normal, Student t, Uniform,
|
28
|
+
and Weibull. Ported from John D. Cook's C# Code.
|
37
29
|
email: jasonmadams@gmail.com
|
38
30
|
executables: []
|
39
|
-
|
40
31
|
extensions: []
|
41
|
-
|
42
|
-
extra_rdoc_files:
|
32
|
+
extra_rdoc_files:
|
43
33
|
- LICENSE
|
44
34
|
- README.rdoc
|
45
|
-
files:
|
35
|
+
files:
|
46
36
|
- .document
|
47
|
-
- .gitignore
|
48
37
|
- LICENSE
|
49
38
|
- README.rdoc
|
50
39
|
- Rakefile
|
@@ -53,40 +42,28 @@ files:
|
|
53
42
|
- simple-random.gemspec
|
54
43
|
- test/helper.rb
|
55
44
|
- test/test_simple_random.rb
|
56
|
-
has_rdoc: true
|
57
45
|
homepage: http://github.com/ealdent/simple-random
|
58
46
|
licenses: []
|
59
|
-
|
60
47
|
post_install_message:
|
61
|
-
rdoc_options:
|
62
|
-
|
63
|
-
require_paths:
|
48
|
+
rdoc_options: []
|
49
|
+
require_paths:
|
64
50
|
- lib
|
65
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
51
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
66
52
|
none: false
|
67
|
-
requirements:
|
68
|
-
- -
|
69
|
-
- !ruby/object:Gem::Version
|
70
|
-
|
71
|
-
|
72
|
-
- 0
|
73
|
-
version: "0"
|
74
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
53
|
+
requirements:
|
54
|
+
- - ! '>='
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: '0'
|
57
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
75
58
|
none: false
|
76
|
-
requirements:
|
77
|
-
- -
|
78
|
-
- !ruby/object:Gem::Version
|
79
|
-
|
80
|
-
segments:
|
81
|
-
- 0
|
82
|
-
version: "0"
|
59
|
+
requirements:
|
60
|
+
- - ! '>='
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0'
|
83
63
|
requirements: []
|
84
|
-
|
85
64
|
rubyforge_project:
|
86
|
-
rubygems_version: 1.
|
65
|
+
rubygems_version: 1.8.7
|
87
66
|
signing_key:
|
88
67
|
specification_version: 3
|
89
68
|
summary: Simple Random Number Generator
|
90
|
-
test_files:
|
91
|
-
- test/helper.rb
|
92
|
-
- test/test_simple_random.rb
|
69
|
+
test_files: []
|