malge 0.0.6 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGES +9 -1
- data/Gemfile +1 -1
- data/VERSION +1 -1
- data/lib/malge.rb +2 -2
- data/lib/malge/errorfittedfunction.rb +13 -14
- data/lib/malge/errorfittedfunction/aexpbx.rb +10 -2
- data/lib/malge/errorfittedfunction/aexpbx32.rb +9 -3
- data/lib/malge/errorfittedfunction/axinv.rb +11 -6
- data/lib/malge/errorfittedfunction/axinv2.rb +33 -0
- data/lib/malge/errorfittedfunction/axinv3.rb +33 -0
- data/lib/malge/errorfittedfunction/axinv32.rb +8 -4
- data/lib/malge/leastsquare.rb +0 -6
- data/lib/malge/simultaneousequations.rb +0 -1
- data/malge.gemspec +7 -10
- data/test/test_errorfittedfunction.rb +87 -20
- data/test/test_errorfittedfunction_aexpbx.rb +14 -6
- data/test/test_errorfittedfunction_aexpbx32.rb +17 -10
- data/test/test_errorfittedfunction_axinv.rb +23 -21
- data/test/test_errorfittedfunction_axinv2.rb +97 -0
- data/test/test_errorfittedfunction_axinv3.rb +95 -0
- data/test/test_errorfittedfunction_axinv32.rb +19 -38
- data/test/test_leastsquare.rb +13 -2
- data/test/test_simultaneousequations.rb +3 -3
- metadata +16 -52
- data/lib/malge/errorfittedfunction/axinv32plusb.rb +0 -32
- data/lib/malge/errorfittedfunction/axinvplusb.rb +0 -32
- data/test/test_errorfittedfunction_axinv32plusb.rb +0 -67
- data/test/test_errorfittedfunction_axinvplusb.rb +0 -50
@@ -1,16 +1,19 @@
|
|
1
1
|
#! /usr/bin/env ruby
|
2
2
|
# coding: utf-8
|
3
3
|
|
4
|
-
require "
|
5
|
-
require "
|
6
|
-
require "malge
|
4
|
+
require "helper"
|
5
|
+
#require "test/unit"
|
6
|
+
#require "malge.rb"
|
7
|
+
#require "malge/errorfittedfunction.rb"
|
7
8
|
|
8
9
|
class Malge::ErrorFittedFunction::AExpBX
|
9
10
|
public :fit
|
10
11
|
end
|
11
12
|
|
12
13
|
class TC_ErrorFittedFunction_AExpBX < Test::Unit::TestCase
|
14
|
+
|
13
15
|
TOLERANCE = 1.0E-10
|
16
|
+
|
14
17
|
def setup
|
15
18
|
@aebx00 = Malge::ErrorFittedFunction::AExpBX.new(
|
16
19
|
[
|
@@ -34,6 +37,10 @@ class TC_ErrorFittedFunction_AExpBX < Test::Unit::TestCase
|
|
34
37
|
#def test_initialize
|
35
38
|
#end
|
36
39
|
|
40
|
+
def test_equation
|
41
|
+
assert_equal("f(x) = 4.000000 * exp(-0.693147 * x)", @aebx00.equation)
|
42
|
+
end
|
43
|
+
|
37
44
|
def test_fit
|
38
45
|
corrects = [4.0, - Math::log(2.0)]
|
39
46
|
results = @aebx00.coefficients
|
@@ -55,12 +62,13 @@ class TC_ErrorFittedFunction_AExpBX < Test::Unit::TestCase
|
|
55
62
|
assert_in_delta(0.5, @aebx00.expected_error(3.0), TOLERANCE)
|
56
63
|
end
|
57
64
|
|
58
|
-
def
|
59
|
-
|
65
|
+
def test_most_strict
|
66
|
+
assert_in_delta( 3.0, @aebx00.most_strict_pair[0])
|
67
|
+
assert_in_delta(100.0, @aebx00.most_strict_pair[1])
|
60
68
|
end
|
61
69
|
|
62
70
|
def test_variance
|
63
|
-
assert_in_delta( 0.
|
71
|
+
assert_in_delta( 0.25, @aebx00.variance, TOLERANCE)
|
64
72
|
#diff_abs = [4,1]
|
65
73
|
#expected = [1,3]
|
66
74
|
end
|
@@ -1,9 +1,10 @@
|
|
1
1
|
#! /usr/bin/env ruby
|
2
2
|
# coding: utf-8
|
3
3
|
|
4
|
-
require "
|
5
|
-
require "
|
6
|
-
#require "malge
|
4
|
+
require "helper"
|
5
|
+
#require "test/unit"
|
6
|
+
#require "malge.rb"
|
7
|
+
##require "malge/errorfittedfunction.rb"
|
7
8
|
|
8
9
|
class Malge::ErrorFittedFunction::AExpBX32
|
9
10
|
public :fit
|
@@ -34,6 +35,11 @@ class TC_ErrorFittedFunction_AExpBX32 < Test::Unit::TestCase
|
|
34
35
|
#def test_initialize
|
35
36
|
#end
|
36
37
|
|
38
|
+
def test_equation
|
39
|
+
assert_equal("f(x) = 3.000000 * exp(-1.386294 * x^{3/2})", @aebx00.equation)
|
40
|
+
end
|
41
|
+
|
42
|
+
|
37
43
|
def test_fit
|
38
44
|
corrects = [3.0, - 2.0*Math::log(2.0)]
|
39
45
|
results = @aebx00.coefficients
|
@@ -51,7 +57,7 @@ class TC_ErrorFittedFunction_AExpBX32 < Test::Unit::TestCase
|
|
51
57
|
def test_expected_error
|
52
58
|
corrects =
|
53
59
|
[
|
54
|
-
3.0* 2.0**(-2.0 * 0.0)
|
60
|
+
3.0* 2.0**(-2.0 * 0.0),
|
55
61
|
3.0* 2.0**(-2.0 * 1.0),
|
56
62
|
3.0* 2.0**(-2.0 * (2.0**(3.0/2.0)))
|
57
63
|
]
|
@@ -61,7 +67,7 @@ class TC_ErrorFittedFunction_AExpBX32 < Test::Unit::TestCase
|
|
61
67
|
|
62
68
|
corrects =
|
63
69
|
[
|
64
|
-
3.0* 2.0**(-2.0 * 0.0)
|
70
|
+
3.0* 2.0**(-2.0 * 0.0),
|
65
71
|
3.0* 2.0**(-2.0 * 1.0),
|
66
72
|
3.0* 2.0**(-2.0 * (2.0**(3.0/2.0)))
|
67
73
|
]
|
@@ -71,14 +77,15 @@ class TC_ErrorFittedFunction_AExpBX32 < Test::Unit::TestCase
|
|
71
77
|
|
72
78
|
end
|
73
79
|
|
74
|
-
def
|
75
|
-
|
76
|
-
|
80
|
+
def test_most_strict_pair
|
81
|
+
assert_in_delta( 3.0, @aebx00.most_strict_pair[0])
|
82
|
+
assert_in_delta(100.0, @aebx00.most_strict_pair[1])
|
77
83
|
end
|
78
84
|
|
79
85
|
def test_variance
|
80
|
-
|
81
|
-
assert_in_delta(
|
86
|
+
correct = ( 3.0* 2.0**(-2.0 * (3.0**(3.0/2.0))))**2.0
|
87
|
+
assert_in_delta(correct, @aebx00.variance, TOLERANCE)
|
88
|
+
assert_in_delta(correct, @aebx01.variance, TOLERANCE)
|
82
89
|
end
|
83
90
|
|
84
91
|
def test_x
|
@@ -1,48 +1,50 @@
|
|
1
1
|
#! /usr/bin/env ruby
|
2
2
|
# coding: utf-8
|
3
3
|
|
4
|
-
require "
|
5
|
-
require "
|
6
|
-
require "malge
|
4
|
+
require "helper"
|
5
|
+
#require "test/unit"
|
6
|
+
#require "malge.rb"
|
7
|
+
#require "malge/errorfittedfunction.rb"
|
7
8
|
|
8
9
|
class TC_ErrorFittedFunction_AXInv < Test::Unit::TestCase
|
10
|
+
|
11
|
+
$tolerance = 1E-10
|
12
|
+
|
9
13
|
def setup
|
10
|
-
@
|
14
|
+
@axi00 = Malge::ErrorFittedFunction::AXInv.new(
|
11
15
|
[
|
12
|
-
[1.0,
|
13
|
-
[
|
14
|
-
[4.0, 5.0],
|
15
|
-
[8.0, 4.0],
|
16
|
+
[1.0, 1.0],
|
17
|
+
[0.5, 3.0],
|
16
18
|
]
|
17
19
|
)
|
18
20
|
end
|
19
21
|
|
20
|
-
|
21
|
-
|
22
|
+
def test_equation
|
23
|
+
assert_equal("f(x) = 0.800000 / x", @axi00.equation)
|
24
|
+
end
|
22
25
|
|
23
26
|
def test_fit
|
24
|
-
|
27
|
+
assert_in_delta(0.8, @axi00.coefficients[0], $tolerance)
|
25
28
|
end
|
26
29
|
|
27
30
|
def test_expected_error
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
assert_equal(0.5, @axi01.expected_error(8.0))
|
31
|
+
assert_in_delta(0.8, @axi00.expected_error(1.0), $tolerance)
|
32
|
+
assert_in_delta(0.4, @axi00.expected_error(2.0), $tolerance)
|
33
|
+
|
32
34
|
end
|
33
35
|
|
34
|
-
def
|
35
|
-
|
36
|
+
def test_most_strict_pair
|
37
|
+
assert_in_delta( 1.0, @axi00.most_strict_pair[0])
|
38
|
+
assert_in_delta( 1.0, @axi00.most_strict_pair[1])
|
36
39
|
end
|
37
40
|
|
41
|
+
|
38
42
|
def test_variance
|
39
|
-
assert_equal( 0.
|
40
|
-
#diff_abs = [4,1]
|
41
|
-
#expected = [1,3]
|
43
|
+
assert_equal( 0.8, @axi00.variance)
|
42
44
|
end
|
43
45
|
|
44
46
|
def test_x
|
45
|
-
|
47
|
+
assert_in_delta(1.0, @axi00.x(0.8), $tolerance)
|
46
48
|
end
|
47
49
|
|
48
50
|
end
|
@@ -0,0 +1,97 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
# coding: utf-8
|
3
|
+
|
4
|
+
require "helper"
|
5
|
+
#require "test/unit"
|
6
|
+
#require "malge.rb"
|
7
|
+
|
8
|
+
class TC_ErrorFittedFunction_AXInv2 < Test::Unit::TestCase
|
9
|
+
|
10
|
+
$tolerance = 1E-10
|
11
|
+
|
12
|
+
def setup
|
13
|
+
@axi200 = Malge::ErrorFittedFunction::AXInv2.new(
|
14
|
+
[
|
15
|
+
[1.0, 1.0],
|
16
|
+
[2.0**(-1.0/2.0), 3.0],
|
17
|
+
]
|
18
|
+
)
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_equation
|
22
|
+
assert_equal("f(x) = 0.800000 / (x^2)", @axi200.equation)
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_fit
|
26
|
+
assert_in_delta(0.8, @axi200.coefficients[0], $tolerance)
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_expected_error
|
30
|
+
assert_in_delta(0.8, @axi200.expected_error(1.0), $tolerance)
|
31
|
+
assert_in_delta(1.6, @axi200.expected_error(2.0**(-1.0/2.0)), $tolerance)
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_most_strict_pair
|
35
|
+
assert_in_delta( 1.0, @axi200.most_strict_pair[0])
|
36
|
+
assert_in_delta( 1.0, @axi200.most_strict_pair[1])
|
37
|
+
end
|
38
|
+
|
39
|
+
|
40
|
+
def test_variance
|
41
|
+
assert_in_delta( 0.8, @axi200.variance, $tolerance)
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_x
|
45
|
+
assert_in_delta(1.0, @axi200.x(0.8), $tolerance)
|
46
|
+
end
|
47
|
+
|
48
|
+
|
49
|
+
#def setup
|
50
|
+
# @axi201 = Malge::ErrorFittedFunction::AXInv2.new(
|
51
|
+
# [
|
52
|
+
# [1.0, 20.0],
|
53
|
+
# [2.0, 8.0],
|
54
|
+
# [4.0, 5.0],
|
55
|
+
# [8.0, 4.0],
|
56
|
+
# ]
|
57
|
+
# )
|
58
|
+
#end
|
59
|
+
|
60
|
+
##def test_initialize
|
61
|
+
##end
|
62
|
+
|
63
|
+
#def test_equation
|
64
|
+
# assert_equal("f(x) = 16.000000 / (x^2)", @axi201.equation)
|
65
|
+
#end
|
66
|
+
|
67
|
+
#def test_fit
|
68
|
+
# assert_equal([16.0], @axi201.coefficients)
|
69
|
+
#end
|
70
|
+
|
71
|
+
#def test_expected_error
|
72
|
+
# assert_equal(16.0 , @axi201.expected_error(1.0))
|
73
|
+
# assert_equal( 4.0 , @axi201.expected_error(2.0))
|
74
|
+
# assert_equal( 1.0 , @axi201.expected_error(4.0))
|
75
|
+
# assert_equal( 0.25, @axi201.expected_error(8.0))
|
76
|
+
#end
|
77
|
+
|
78
|
+
#def test_most_strict_y
|
79
|
+
# assert_equal( 4.0, @axi201.most_strict_y)
|
80
|
+
#end
|
81
|
+
|
82
|
+
#def test_most_strict_x
|
83
|
+
# assert_equal(8.0, @axi201.most_strict_x)
|
84
|
+
#end
|
85
|
+
|
86
|
+
#def test_variance
|
87
|
+
# assert_equal( 0.0, @axi201.variance)
|
88
|
+
# #diff_abs = [4,1]
|
89
|
+
# #expected = [1,3]
|
90
|
+
#end
|
91
|
+
|
92
|
+
#def test_x
|
93
|
+
# assert_equal(2.0, @axi201.x(4.0))
|
94
|
+
#end
|
95
|
+
|
96
|
+
end
|
97
|
+
|
@@ -0,0 +1,95 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
# coding: utf-8
|
3
|
+
|
4
|
+
require "helper"
|
5
|
+
#require "test/unit"
|
6
|
+
#require "malge.rb"
|
7
|
+
|
8
|
+
class TC_ErrorFittedFunction_AXInv3 < Test::Unit::TestCase
|
9
|
+
$tolerance = 1E-10
|
10
|
+
|
11
|
+
def setup
|
12
|
+
@axi300 = Malge::ErrorFittedFunction::AXInv3.new(
|
13
|
+
[
|
14
|
+
[1.0, 1.0],
|
15
|
+
[2.0**(-1.0/3.0), 3.0],
|
16
|
+
]
|
17
|
+
)
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_equation
|
21
|
+
assert_equal("f(x) = 0.800000 / (x^3)", @axi300.equation)
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_fit
|
25
|
+
assert_in_delta(0.8, @axi300.coefficients[0], $tolerance)
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_expected_error
|
29
|
+
assert_in_delta(0.8, @axi300.expected_error(1.0), $tolerance)
|
30
|
+
assert_in_delta(1.6, @axi300.expected_error(2.0**(-1.0/3.0)), $tolerance)
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_most_strict_pair
|
34
|
+
assert_in_delta( 1.0, @axi300.most_strict_pair[0])
|
35
|
+
assert_in_delta( 1.0, @axi300.most_strict_pair[1])
|
36
|
+
end
|
37
|
+
|
38
|
+
|
39
|
+
def test_variance
|
40
|
+
assert_in_delta( 0.8, @axi300.variance, $tolerance)
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_x
|
44
|
+
assert_in_delta(1.0, @axi300.x(0.8), $tolerance)
|
45
|
+
end
|
46
|
+
|
47
|
+
#def setup
|
48
|
+
# @axi301 = Malge::ErrorFittedFunction::AXInv3.new(
|
49
|
+
# [
|
50
|
+
# [1.0, 68.0],
|
51
|
+
# [2.0, 12.0],
|
52
|
+
# [4.0, 5.0],
|
53
|
+
# [8.0, 4.0],
|
54
|
+
# ]
|
55
|
+
# )
|
56
|
+
#end
|
57
|
+
|
58
|
+
##def test_initialize
|
59
|
+
##end
|
60
|
+
|
61
|
+
#def test_equation
|
62
|
+
# assert_equal("f(x) = 64.000000 / (x^3)", @axi301.equation)
|
63
|
+
#end
|
64
|
+
|
65
|
+
#def test_fit
|
66
|
+
# assert_equal([64.0], @axi301.coefficients)
|
67
|
+
#end
|
68
|
+
|
69
|
+
#def test_expected_error
|
70
|
+
# assert_equal(64.0 , @axi301.expected_error(1.0))
|
71
|
+
# assert_equal( 8.0 , @axi301.expected_error(2.0))
|
72
|
+
# assert_equal( 1.0 , @axi301.expected_error(4.0))
|
73
|
+
# assert_equal( 0.125, @axi301.expected_error(8.0))
|
74
|
+
#end
|
75
|
+
|
76
|
+
#def test_most_strict_y
|
77
|
+
# assert_equal( 4.0, @axi301.most_strict_y)
|
78
|
+
#end
|
79
|
+
|
80
|
+
#def test_most_strict_x
|
81
|
+
# assert_equal(8.0, @axi301.most_strict_x)
|
82
|
+
#end
|
83
|
+
|
84
|
+
#def test_variance
|
85
|
+
# assert_equal( 0.0, @axi301.variance)
|
86
|
+
# #diff_abs = [4,1]
|
87
|
+
# #expected = [1,3]
|
88
|
+
#end
|
89
|
+
|
90
|
+
#def test_x
|
91
|
+
# assert_equal(2.0, @axi301.x(8.0))
|
92
|
+
#end
|
93
|
+
|
94
|
+
end
|
95
|
+
|
@@ -1,67 +1,48 @@
|
|
1
1
|
#! /usr/bin/env ruby
|
2
2
|
# coding: utf-8
|
3
3
|
|
4
|
-
require "
|
5
|
-
require "
|
6
|
-
#require "malge
|
4
|
+
require "helper"
|
5
|
+
#require "test/unit"
|
6
|
+
#require "malge.rb"
|
7
|
+
##require "malge/errorfittedfunction.rb"
|
7
8
|
|
8
9
|
class TC_ErrorFittedFunction_AXInv32 < Test::Unit::TestCase
|
9
|
-
|
10
|
+
$tolerance = 1E-10
|
10
11
|
|
11
12
|
def setup
|
12
|
-
@
|
13
|
+
@axi3200 = Malge::ErrorFittedFunction::AXInv32.new(
|
13
14
|
[
|
14
|
-
[
|
15
|
-
[
|
16
|
-
[16, 101.0],
|
17
|
-
[64, 100.0],
|
15
|
+
[1.0, 1.0],
|
16
|
+
[2.0, 3.0],
|
18
17
|
]
|
19
18
|
)
|
20
|
-
|
21
|
-
@axi01 = Malge::ErrorFittedFunction::AXInv32.new(
|
22
|
-
[
|
23
|
-
[ 1, 164.0],
|
24
|
-
[ 4, 92.0],
|
25
|
-
[16, 101.0],
|
26
|
-
[64, 100.0],
|
27
|
-
]
|
28
|
-
)
|
29
|
-
|
30
19
|
end
|
31
20
|
|
32
|
-
|
33
|
-
|
21
|
+
def test_equation
|
22
|
+
assert_equal("f(x) = 1.777778 / (x^{3/2})", @axi3200.equation)
|
23
|
+
end
|
34
24
|
|
35
25
|
def test_fit
|
36
|
-
|
37
|
-
results = @axi00.coefficients
|
38
|
-
assert_equal(1, results.size)
|
39
|
-
assert_in_delta(corrects[0], results[0], TOLERANCE)
|
26
|
+
assert_in_delta(16.0/9.0, @axi3200.coefficients[0], $tolerance)
|
40
27
|
end
|
41
28
|
|
42
29
|
def test_expected_error
|
43
|
-
|
44
|
-
|
45
|
-
assert_equal( 1.0, @axi00.expected_error(16.0))
|
30
|
+
assert_in_delta(16.0/9.0, @axi3200.expected_error(1.0), $tolerance)
|
31
|
+
assert_in_delta(16.0/9.0 * 2.0**(-3.0/2.0), @axi3200.expected_error(2.0), $tolerance)
|
46
32
|
|
47
|
-
assert_equal(64.0, @axi01.expected_error(1.0))
|
48
|
-
assert_equal( 8.0, @axi01.expected_error(4.0))
|
49
|
-
assert_equal( 1.0, @axi01.expected_error(16.0))
|
50
33
|
end
|
51
34
|
|
52
|
-
def
|
53
|
-
|
54
|
-
|
35
|
+
def test_most_strict_pair
|
36
|
+
assert_in_delta( 2.0, @axi3200.most_strict_pair[0])
|
37
|
+
assert_in_delta( 3.0, @axi3200.most_strict_pair[1])
|
55
38
|
end
|
56
39
|
|
57
40
|
def test_variance
|
58
|
-
assert_equal(
|
59
|
-
assert_equal( 0.0, @axi01.variance)
|
41
|
+
assert_equal(36.0/81.0, @axi3200.variance)
|
60
42
|
end
|
61
43
|
|
62
44
|
def test_x
|
63
|
-
assert_in_delta(
|
45
|
+
assert_in_delta(1.0, @axi3200.x(16.0/9.0), $tolerance)
|
64
46
|
end
|
65
|
-
|
66
47
|
end
|
67
48
|
|