quasi 0.0.1 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- metadata +42 -28
- data/Manifest +0 -7
- data/Rakefile +0 -26
- data/lib/LowDiscrepancySequence.rb +0 -164
- data/lib/NX.rb +0 -1385
- data/lib/halton.rb +0 -93
- data/lib/quasi.rb +0 -18
- data/quasi.gemspec +0 -30
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: quasi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 25
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 3
|
10
|
+
version: 0.0.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Thomas Adolfsson
|
@@ -17,37 +17,52 @@ cert_chain: []
|
|
17
17
|
|
18
18
|
date: 2010-09-15 00:00:00 +10:00
|
19
19
|
default_executable:
|
20
|
-
dependencies:
|
21
|
-
|
22
|
-
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: minitest
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 3
|
30
|
+
segments:
|
31
|
+
- 0
|
32
|
+
version: "0"
|
33
|
+
type: :development
|
34
|
+
version_requirements: *id001
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: narray
|
37
|
+
prerelease: false
|
38
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
hash: 3
|
44
|
+
segments:
|
45
|
+
- 0
|
46
|
+
version: "0"
|
47
|
+
type: :runtime
|
48
|
+
version_requirements: *id002
|
49
|
+
description: A gem for Low Discrepancy Sequences. Currently Contains implementations of the Halton, and Niederreiter-Xing generator in various dimensions
|
23
50
|
email: thoad747@gmail.com
|
24
51
|
executables: []
|
25
52
|
|
26
53
|
extensions: []
|
27
54
|
|
28
|
-
extra_rdoc_files:
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
- lib/quasi.rb
|
33
|
-
files:
|
34
|
-
- Manifest
|
35
|
-
- Rakefile
|
36
|
-
- lib/LowDiscrepancySequence.rb
|
37
|
-
- lib/NX.rb
|
38
|
-
- lib/halton.rb
|
39
|
-
- lib/quasi.rb
|
40
|
-
- quasi.gemspec
|
55
|
+
extra_rdoc_files: []
|
56
|
+
|
57
|
+
files: []
|
58
|
+
|
41
59
|
has_rdoc: true
|
42
60
|
homepage: http://gammabox.heroku.com
|
43
61
|
licenses: []
|
44
62
|
|
45
63
|
post_install_message:
|
46
64
|
rdoc_options:
|
47
|
-
- --
|
48
|
-
- --inline-source
|
49
|
-
- --title
|
50
|
-
- Quasi
|
65
|
+
- --charset=UTF-8
|
51
66
|
require_paths:
|
52
67
|
- lib
|
53
68
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -64,14 +79,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
64
79
|
requirements:
|
65
80
|
- - ">="
|
66
81
|
- !ruby/object:Gem::Version
|
67
|
-
hash:
|
82
|
+
hash: 3
|
68
83
|
segments:
|
69
|
-
-
|
70
|
-
|
71
|
-
version: "1.2"
|
84
|
+
- 0
|
85
|
+
version: "0"
|
72
86
|
requirements: []
|
73
87
|
|
74
|
-
rubyforge_project:
|
88
|
+
rubyforge_project:
|
75
89
|
rubygems_version: 1.3.7
|
76
90
|
signing_key:
|
77
91
|
specification_version: 3
|
data/Manifest
DELETED
data/Rakefile
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'rake'
|
3
|
-
require 'echoe'
|
4
|
-
#require 'spec/rake/spectask'
|
5
|
-
require 'lib/quasi'
|
6
|
-
|
7
|
-
#task :default => :spec
|
8
|
-
|
9
|
-
#desc "Run the Quasi specs"
|
10
|
-
#task :spec do
|
11
|
-
# Spec::Rake::SpecTask.new do |t|
|
12
|
-
# t.spec_files = FileList['spec/**/*_spec.rb']
|
13
|
-
# t.rcov = true
|
14
|
-
# t.rcov_opts = ['--exclude', 'spec']
|
15
|
-
# t.spec_opts = ['--options', "spec/spec.opts"]
|
16
|
-
# end
|
17
|
-
#end
|
18
|
-
|
19
|
-
Echoe.new('quasi', "0.0.1") do |p|
|
20
|
-
p.description = "A gem for Low Discrepancy Sequences"
|
21
|
-
p.url = "http://gammabox.heroku.com"
|
22
|
-
p.author = "Thomas Adolfsson"
|
23
|
-
p.email = "thoad747@gmail.com"
|
24
|
-
p.ignore_pattern = ["coverage/*", "*~"]
|
25
|
-
p.development_dependencies = []
|
26
|
-
end
|
@@ -1,164 +0,0 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require 'rubygems'
|
4
|
-
require 'narray'
|
5
|
-
include Math
|
6
|
-
|
7
|
-
#p>Interface and methods to compute L2-discrepancy for low discrepancy sequences.</p>
|
8
|
-
|
9
|
-
module Quasi
|
10
|
-
|
11
|
-
class LowDiscrepancySequence
|
12
|
-
|
13
|
-
def initialize(dim)
|
14
|
-
@dim = dim
|
15
|
-
@index = 1
|
16
|
-
@x = NArray.float(dim)
|
17
|
-
@y = NArray.float(dim)
|
18
|
-
end
|
19
|
-
|
20
|
-
def restart
|
21
|
-
@index =1
|
22
|
-
end
|
23
|
-
|
24
|
-
def nextPoint(r)
|
25
|
-
x= nextPoint
|
26
|
-
for k in 0..@dim
|
27
|
-
r[k] = x[k]
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
#L^2-DISCREPANCY
|
32
|
-
|
33
|
-
def product(i,j,r)
|
34
|
-
f=1.0
|
35
|
-
for k in 0..@dim
|
36
|
-
f*=1.0-[r[i][k],r[j][k]].max
|
37
|
-
end
|
38
|
-
return f
|
39
|
-
end
|
40
|
-
|
41
|
-
def productSQ( i, r)
|
42
|
-
f=1.0
|
43
|
-
for k in 0..@dim
|
44
|
-
f*=(1.0-r[i][k]*r[i][k])
|
45
|
-
end
|
46
|
-
return f
|
47
|
-
end
|
48
|
-
|
49
|
-
|
50
|
-
def L2_discrepancy(n, r)
|
51
|
-
a,b =1.0,1.0
|
52
|
-
for k in 0..@dim
|
53
|
-
a/=2
|
54
|
-
b/=3
|
55
|
-
end
|
56
|
-
|
57
|
-
sum_1,sum_2 =0.0,0.0
|
58
|
-
|
59
|
-
loops=0
|
60
|
-
for i in 0..n
|
61
|
-
for j in i+1..n
|
62
|
-
sum_1+=product(i,j,r)
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
sum_1*=2
|
67
|
-
|
68
|
-
for i in 0..n
|
69
|
-
sum_1+=product(i,i,r)
|
70
|
-
end
|
71
|
-
|
72
|
-
sum_1/=(n*n)
|
73
|
-
|
74
|
-
#second sum
|
75
|
-
for i in 0..n
|
76
|
-
sum_2+=productSQ(i,r)
|
77
|
-
end
|
78
|
-
|
79
|
-
sum_2/=n
|
80
|
-
sum_2*=(2.0*a)
|
81
|
-
return Math.sqrt(sum_1-sum_2+b)
|
82
|
-
|
83
|
-
end
|
84
|
-
|
85
|
-
#second method for all
|
86
|
-
#add later
|
87
|
-
|
88
|
-
# TRANSFORM UNIFORM -> MULTINORMAL
|
89
|
-
#need thi, maybe narray
|
90
|
-
|
91
|
-
def nextQuasiNormalVector
|
92
|
-
x=nextPoint()
|
93
|
-
z = Array.new(@dim)
|
94
|
-
for k in 0..@dim-1
|
95
|
-
z[k]=n_inverse(x[k].to_f);
|
96
|
-
end
|
97
|
-
return z
|
98
|
-
end
|
99
|
-
|
100
|
-
def projectionOut(i,j, nPoints)
|
101
|
-
name=getName
|
102
|
-
puts i,j
|
103
|
-
puts nextPoint(x)
|
104
|
-
end
|
105
|
-
|
106
|
-
def n_inverse(x)
|
107
|
-
sqrt_two_PI=2.5066282746310
|
108
|
-
|
109
|
-
e_1 = -3.969683028665376e+01
|
110
|
-
e_2 = 2.209460984245205e+02
|
111
|
-
e_3 = -2.759285104469687e+02
|
112
|
-
e_4 = 1.383577518672690e+02
|
113
|
-
e_5 = -3.066479806614716e+01
|
114
|
-
e_6 = 2.506628277459239e+00
|
115
|
-
|
116
|
-
f_1 = -5.447609879822406e+01
|
117
|
-
f_2 = 1.615858368580409e+02
|
118
|
-
f_3 = -1.556989798598866e+02
|
119
|
-
f_4 = 6.680131188771972e+01
|
120
|
-
f_5 = -1.328068155288572e+01
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
g_1 = -7.784894002430293e-03
|
125
|
-
g_2 = -3.223964580411365e-01
|
126
|
-
g_3 = -2.400758277161838e+00
|
127
|
-
g_4 = -2.549732539343734e+00
|
128
|
-
g_5 = 4.374664141464968e+00
|
129
|
-
g_6 = 2.938163982698783e+00
|
130
|
-
|
131
|
-
|
132
|
-
h_1 = 7.784695709041462e-03
|
133
|
-
h_2 = 3.224671290700398e-01
|
134
|
-
h_3 = 2.445134137142996e+00
|
135
|
-
h_4 = 3.754408661907416e+00
|
136
|
-
|
137
|
-
x_l = 0.02425
|
138
|
-
x_u = 1.0 - x_l
|
139
|
-
|
140
|
-
|
141
|
-
#lower
|
142
|
-
|
143
|
-
if( x < x_l )
|
144
|
-
z = Math.sqrt(-2.0*Math.log(x))
|
145
|
-
z = (((((g_1*z+g_2)*z+g_3)*z+g_4)*z+g_5)*z+g_6) / ((((h_1*z+h_2)*z+h_3)*z+h_4)*z+1.0)
|
146
|
-
elsif( x <= x_u )
|
147
|
-
#central
|
148
|
-
z = x - 0.5; r = z*z
|
149
|
-
z = (((((e_1*r+e_2)*r+e_3)*r+e_4)*r+e_5)*r+e_6)*z / (((((f_1*r+f_2)*r+f_3)*r+f_4)*r+f_5)*r+1.0)
|
150
|
-
|
151
|
-
#upper
|
152
|
-
else
|
153
|
-
z = Math.sqrt(-2.0*Math.log(1.0-x))
|
154
|
-
z = -(((((g_1*z+g_2)*z+g_3)*z+g_4)*z+g_5)*z+g_6) / ((((h_1*z+h_2)*z+h_3)*z+h_4)*z+1.0)
|
155
|
-
|
156
|
-
end
|
157
|
-
|
158
|
-
return z
|
159
|
-
|
160
|
-
|
161
|
-
end
|
162
|
-
|
163
|
-
end #end of class
|
164
|
-
end # end module
|