distribution 0.6.0 → 0.8.0

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.
Files changed (117) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +7 -0
  3. data/.travis.yml +13 -0
  4. data/.yardopts +5 -0
  5. data/Gemfile +5 -0
  6. data/History.txt +24 -8
  7. data/LICENCE.md +26 -0
  8. data/README.md +155 -0
  9. data/Rakefile +15 -19
  10. data/benchmark/binomial_coefficient.rb +19 -23
  11. data/benchmark/binomial_coefficient/experiment.rb +33 -36
  12. data/benchmark/factorial_hash.rb +7 -8
  13. data/benchmark/factorial_method.rb +4 -6
  14. data/benchmark/odd.rb +6 -7
  15. data/benchmark/power.rb +11 -11
  16. data/bin/distribution +26 -26
  17. data/data/template/spec.erb +7 -6
  18. data/distribution.gemspec +25 -0
  19. data/lib/distribution.rb +79 -124
  20. data/lib/distribution/beta.rb +6 -8
  21. data/lib/distribution/beta/gsl.rb +14 -9
  22. data/lib/distribution/beta/java.rb +1 -1
  23. data/lib/distribution/beta/ruby.rb +41 -7
  24. data/lib/distribution/binomial.rb +10 -11
  25. data/lib/distribution/binomial/gsl.rb +6 -5
  26. data/lib/distribution/binomial/java.rb +1 -1
  27. data/lib/distribution/binomial/ruby.rb +22 -15
  28. data/lib/distribution/bivariatenormal.rb +4 -5
  29. data/lib/distribution/bivariatenormal/gsl.rb +2 -2
  30. data/lib/distribution/bivariatenormal/java.rb +1 -1
  31. data/lib/distribution/bivariatenormal/ruby.rb +245 -254
  32. data/lib/distribution/chisquare.rb +8 -10
  33. data/lib/distribution/chisquare/gsl.rb +24 -19
  34. data/lib/distribution/chisquare/java.rb +1 -1
  35. data/lib/distribution/chisquare/ruby.rb +60 -55
  36. data/lib/distribution/chisquare/statistics2.rb +16 -13
  37. data/lib/distribution/distributable.rb +40 -0
  38. data/lib/distribution/exponential.rb +4 -5
  39. data/lib/distribution/exponential/gsl.rb +13 -9
  40. data/lib/distribution/exponential/ruby.rb +17 -11
  41. data/lib/distribution/f.rb +10 -11
  42. data/lib/distribution/f/gsl.rb +26 -22
  43. data/lib/distribution/f/java.rb +1 -1
  44. data/lib/distribution/f/ruby.rb +104 -105
  45. data/lib/distribution/f/statistics2.rb +22 -19
  46. data/lib/distribution/gamma.rb +5 -7
  47. data/lib/distribution/gamma/gsl.rb +13 -9
  48. data/lib/distribution/gamma/java.rb +1 -1
  49. data/lib/distribution/gamma/ruby.rb +5 -11
  50. data/lib/distribution/hypergeometric.rb +5 -8
  51. data/lib/distribution/hypergeometric/gsl.rb +5 -6
  52. data/lib/distribution/hypergeometric/java.rb +1 -1
  53. data/lib/distribution/hypergeometric/ruby.rb +34 -35
  54. data/lib/distribution/logistic.rb +6 -9
  55. data/lib/distribution/logistic/ruby.rb +14 -9
  56. data/lib/distribution/lognormal.rb +37 -0
  57. data/lib/distribution/lognormal/gsl.rb +21 -0
  58. data/lib/distribution/lognormal/ruby.rb +16 -0
  59. data/lib/distribution/math_extension.rb +187 -231
  60. data/lib/distribution/math_extension/chebyshev_series.rb +281 -272
  61. data/lib/distribution/math_extension/erfc.rb +28 -31
  62. data/lib/distribution/math_extension/exponential_integral.rb +17 -17
  63. data/lib/distribution/math_extension/gammastar.rb +19 -20
  64. data/lib/distribution/math_extension/gsl_utilities.rb +12 -12
  65. data/lib/distribution/math_extension/incomplete_beta.rb +52 -61
  66. data/lib/distribution/math_extension/incomplete_gamma.rb +166 -168
  67. data/lib/distribution/math_extension/log_utilities.rb +20 -22
  68. data/lib/distribution/normal.rb +11 -13
  69. data/lib/distribution/normal/gsl.rb +13 -10
  70. data/lib/distribution/normal/java.rb +30 -1
  71. data/lib/distribution/normal/ruby.rb +69 -59
  72. data/lib/distribution/normal/statistics2.rb +5 -2
  73. data/lib/distribution/normalmultivariate.rb +64 -64
  74. data/lib/distribution/poisson.rb +12 -14
  75. data/lib/distribution/poisson/gsl.rb +7 -7
  76. data/lib/distribution/poisson/java.rb +26 -0
  77. data/lib/distribution/poisson/ruby.rb +38 -9
  78. data/lib/distribution/shorthand.rb +17 -0
  79. data/lib/distribution/t.rb +16 -16
  80. data/lib/distribution/t/gsl.rb +27 -24
  81. data/lib/distribution/t/java.rb +1 -1
  82. data/lib/distribution/t/ruby.rb +99 -100
  83. data/lib/distribution/t/statistics2.rb +19 -19
  84. data/lib/distribution/uniform.rb +26 -0
  85. data/lib/distribution/uniform/gsl.rb +36 -0
  86. data/lib/distribution/uniform/ruby.rb +91 -0
  87. data/lib/distribution/version.rb +3 -0
  88. data/lib/distribution/weibull.rb +10 -0
  89. data/lib/distribution/weibull/gsl.rb +21 -0
  90. data/lib/distribution/weibull/ruby.rb +34 -0
  91. data/spec/beta_spec.rb +48 -50
  92. data/spec/binomial_spec.rb +80 -84
  93. data/spec/bivariatenormal_spec.rb +28 -35
  94. data/spec/chisquare_spec.rb +49 -52
  95. data/spec/distribution_spec.rb +11 -11
  96. data/spec/exponential_spec.rb +48 -39
  97. data/spec/f_spec.rb +73 -71
  98. data/spec/gamma_spec.rb +50 -53
  99. data/spec/hypergeometric_spec.rb +63 -69
  100. data/spec/logistic_spec.rb +31 -37
  101. data/spec/lognormal_spec.rb +54 -0
  102. data/spec/math_extension_spec.rb +192 -209
  103. data/spec/normal_spec.rb +80 -73
  104. data/spec/poisson_spec.rb +78 -36
  105. data/spec/shorthand_spec.rb +19 -22
  106. data/spec/spec_helper.rb +31 -6
  107. data/spec/t_spec.rb +63 -77
  108. data/spec/uniform_spec.rb +154 -0
  109. data/spec/weibull_spec.rb +17 -0
  110. data/vendor/java/commons-math-2.2.jar +0 -0
  111. metadata +91 -111
  112. data.tar.gz.sig +0 -0
  113. data/.autotest +0 -23
  114. data/.gemtest +0 -0
  115. data/Manifest.txt +0 -95
  116. data/README.txt +0 -100
  117. metadata.gz.sig +0 -0
@@ -1,4 +1,4 @@
1
- $:.unshift(File.expand_path(File.dirname(__FILE__)+"/../lib"))
1
+ $LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__) + '/../lib'))
2
2
  require 'bench_press'
3
3
  require 'distribution'
4
4
  extend BenchPress
@@ -8,17 +8,16 @@ author 'Claudio Bustos'
8
8
  date '2011-01-31'
9
9
  summary "
10
10
  Is better create a lookup table for factorial or just calculate it?
11
- Distribution::MathExtension::SwingFactorial has a lookup table
11
+ Distribution::MathExtension::SwingFactorial has a lookup table
12
12
  for factorials n<20
13
13
  "
14
14
 
15
- reps 1000 #number of repetitions
15
+ reps 1000 # number of repetitions
16
16
 
17
- measure "Lookup" do
18
- Math.factorial(19)
17
+ measure 'Lookup' do
18
+ Math.factorial(19)
19
19
  end
20
20
 
21
- measure "calculate" do
22
- Distribution::MathExtension::SwingFactorial.naive_factorial(19)
21
+ measure 'calculate' do
22
+ Distribution::MathExtension::SwingFactorial.naive_factorial(19)
23
23
  end
24
-
@@ -1,4 +1,4 @@
1
- $:.unshift(File.dirname(__FILE__)+"/../lib")
1
+ $LOAD_PATH.unshift(File.dirname(__FILE__) + '/../lib')
2
2
  require 'distribution'
3
3
  require 'bench_press'
4
4
 
@@ -10,19 +10,17 @@ date '2011-01-27'
10
10
  summary "
11
11
  Factorization requires a lot of processing, so approximation method could be required. But for greats value, bigdecimal are required and things start to get harder.
12
12
  * Approximation (fast_factorial): Luschny f.3
13
- * Exact (factorial): Luschny Swing Prime
13
+ * Exact (factorial): Luschny Swing Prime
14
14
  "
15
15
 
16
- reps 10 #number of repetitions
16
+ reps 10 # number of repetitions
17
17
 
18
- x=200
18
+ x = 200
19
19
 
20
20
  measure "Math.factorial(#{x})" do
21
21
  Math.factorial(x)
22
22
  end
23
23
 
24
24
  measure "Math.fast_factorial(#{x})" do
25
-
26
25
  Math.fast_factorial(x)
27
26
  end
28
-
@@ -10,13 +10,12 @@ summary "
10
10
  Which is faster, n%1==1 or n%2==1
11
11
  "
12
12
 
13
- reps 10_000 #number of repetitions
14
- n=100000
15
- measure "Using &" do
16
- n%1==1
13
+ reps 10_000 # number of repetitions
14
+ n = 100_000
15
+ measure 'Using &' do
16
+ n % 1 == 1
17
17
  end
18
18
 
19
- measure "Using %" do
20
- n%2==1
19
+ measure 'Using %' do
20
+ n.odd?
21
21
  end
22
-
@@ -6,22 +6,22 @@ name 'Float vs Rational power'
6
6
  author 'Claudio Bustos'
7
7
  date '2011-02-02'
8
8
  summary "
9
- On ruby, the maximum size of a float is #{Float::MAX}.
9
+ On ruby, the maximum size of a float is #{Float::MAX}.
10
10
  With Rational, we can raise to integer numbers and surpass Float maximum.
11
11
  What is the speed reduction using Rational?"
12
12
 
13
- reps 1000 #number of repetitions
14
- int=10
15
- rat=10.quo(1)
16
- bd=BigDecimal("10")
17
- measure "Using float pow" do
18
- int**307
13
+ reps 1000 # number of repetitions
14
+ int = 10
15
+ rat = 10.quo(1)
16
+ bd = BigDecimal('10')
17
+ measure 'Using float pow' do
18
+ int**307
19
19
  end
20
20
 
21
- measure "Using rational" do
22
- rat**307
21
+ measure 'Using rational' do
22
+ rat**307
23
23
  end
24
24
 
25
- measure "Using big decimal pow" do
26
- bd**307
25
+ measure 'Using big decimal pow' do
26
+ bd**307
27
27
  end
@@ -3,27 +3,27 @@
3
3
  require 'optparse'
4
4
  require 'fileutils'
5
5
  require 'erb'
6
- gem_base=File.expand_path(File.dirname(__FILE__)+"/..")
7
- require gem_base+"/lib/distribution"
6
+ gem_base = File.expand_path(File.dirname(__FILE__) + '/..')
7
+ require gem_base + '/lib/distribution'
8
8
 
9
- new=false
10
- parameters=""
9
+ new = false
10
+ parameters = ''
11
11
  OptionParser.new do |opts|
12
- opts.banner="Usage: distribution [--new] [--params parameters] distribution"
13
- opts.on("-n", "--new", "Create a new template for distribution") do
14
- new=true
12
+ opts.banner = 'Usage: distribution [--new] [--params parameters] distribution'
13
+ opts.on('-n', '--new', 'Create a new template for distribution') do
14
+ new = true
15
15
  end
16
- opts.on("-PMANDATORY", "--params MANDATORY", String, "Parameters for distribution") do |n_param|
17
- parameters=", #{n_param}"
16
+ opts.on('-PMANDATORY', '--params MANDATORY', String, 'Parameters for distribution') do |n_param|
17
+ parameters = ", #{n_param}"
18
18
  end
19
-
20
- opts.on("-h", "--help", "Show this message") do
19
+
20
+ opts.on('-h', '--help', 'Show this message') do
21
21
  puts opts
22
22
  exit
23
23
  end
24
24
 
25
25
  begin
26
- ARGV << "-h" if ARGV.empty?
26
+ ARGV << '-h' if ARGV.empty?
27
27
  opts.parse!(ARGV)
28
28
  rescue OptionParser::ParseError => e
29
29
  STDERR.puts e.message, "\n", opts
@@ -33,19 +33,19 @@ end
33
33
 
34
34
  ARGV.each do |distribution|
35
35
  if new
36
- basename=distribution.downcase
37
- raise "You should be inside distribution lib directory" unless File.exists? "../distribution.rb"
38
- raise "Distribution already created" if File.exists? basename+".rb"
39
- main=ERB.new(File.read(gem_base+"/data/template/distribution.erb"),)
40
- ruby=ERB.new(File.read(gem_base+"/data/template/distribution/ruby.erb"))
41
- gsl=ERB.new(File.read(gem_base+"/data/template/distribution/gsl.erb"))
42
- spec=ERB.new(File.read(gem_base+"/data/template/spec.erb"))
43
-
44
- FileUtils.mkdir(basename) unless File.exists? basename
45
- File.open(basename+".rb","w") {|fp| fp.write(main.result(binding))}
46
- File.open(basename+"/ruby.rb","w") {|fp| fp.write(ruby.result(binding))}
47
- File.open(basename+"/gsl.rb","w") {|fp| fp.write(gsl.result(binding))}
48
- File.open("../../spec/#{basename}_spec.rb","w") {|fp| fp.write(spec.result(binding))}
49
-
36
+ basename = distribution.downcase
37
+ fail 'You should be inside distribution lib directory' unless File.exist? '../distribution.rb'
38
+ fail 'Distribution already created' if File.exist? basename + '.rb'
39
+ main = ERB.new(File.read(gem_base + '/data/template/distribution.erb'))
40
+ ruby = ERB.new(File.read(gem_base + '/data/template/distribution/ruby.erb'))
41
+ gsl = ERB.new(File.read(gem_base + '/data/template/distribution/gsl.erb'))
42
+ spec = ERB.new(File.read(gem_base + '/data/template/spec.erb'))
43
+
44
+ FileUtils.mkdir(basename) unless File.exist? basename
45
+ File.open(basename + '.rb', 'w') { |fp| fp.write(main.result(binding)) }
46
+ File.open(basename + '/ruby.rb', 'w') { |fp| fp.write(ruby.result(binding)) }
47
+ File.open(basename + '/gsl.rb', 'w') { |fp| fp.write(gsl.result(binding)) }
48
+ File.open("../../spec/#{basename}_spec.rb", 'w') { |fp| fp.write(spec.result(binding)) }
49
+
50
50
  end
51
51
  end
@@ -41,13 +41,14 @@ describe Distribution::<%= distribution.capitalize %> do
41
41
  it_should_behave_like "<%= distribution %> engine"
42
42
 
43
43
  end
44
-
45
- describe Distribution::<%= distribution.capitalize %>::GSL_ do
46
- before do
47
- @engine=Distribution::<%= distribution.capitalize %>::GSL_
44
+
45
+ if Distribution.has_gsl?
46
+ describe Distribution::<%= distribution.capitalize %>::GSL_ do
47
+ before do
48
+ @engine=Distribution::<%= distribution.capitalize %>::GSL_
49
+ end
50
+ it_should_behave_like "<%= distribution %> engine"
48
51
  end
49
- it_should_behave_like "<%= distribution %> engine"
50
-
51
52
  end
52
53
 
53
54
 
@@ -0,0 +1,25 @@
1
+ $LOAD_PATH.unshift File.expand_path('../lib', __FILE__)
2
+
3
+ require 'date'
4
+ require 'distribution/version'
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "distribution"
8
+ s.version = Distribution::VERSION
9
+ s.date = Date.today.to_s
10
+ s.homepage = "https://github.com/sciruby/distribution"
11
+
12
+ s.authors = ['Claudio Bustos', 'Carlos Agarie']
13
+ s.email = ['clbustos@gmail.com', 'carlos.agarie@gmail.com']
14
+ s.platform = Gem::Platform::RUBY
15
+ s.summary = "Distribution"
16
+ s.description = "Distribution is a gem with several probabilistic distributions. Pure Ruby is used by default, C (GSL) or Java extensions are used if available"
17
+
18
+ s.files = `git ls-files`.split("\n")
19
+ s.executables = `git ls-files`.split("\n").map{|f| f =~ /^bin\/(.*)/ ? $1 : nil}.compact
20
+ s.require_path = 'lib'
21
+
22
+ s.add_development_dependency 'bundler'
23
+ s.add_development_dependency 'rake'
24
+ s.add_development_dependency "rspec", '~> 3.2'
25
+ end
@@ -1,157 +1,112 @@
1
- # = distribution.rb -
1
+ # = distribution.rb -
2
2
  # Distribution - Statistical Distributions package for Ruby
3
- #
4
- # Copyright (C) 2011 Claudio Bustos
5
3
  #
6
- # This program is free software; you can redistribute it and/or
7
- # modify it under the terms of the GNU General Public License
8
- # as published by the Free Software Foundation; either version 2
9
- # of the License, or (at your option) any later version.
4
+ # Copyright (c) 2011-2012, Claudio Bustos
5
+ # All rights reserved.
10
6
  #
11
- # This program is distributed in the hope that it will be useful,
12
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
- # GNU General Public License for more details.
15
- #
16
- # You should have received a copy of the GNU General Public License
17
- # along with this program; if not, write to the Free Software
18
- # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
7
+ # Redistribution and use in source and binary forms, with or without
8
+ # modification, are permitted provided that the following conditions are met:
9
+ # * Redistributions of source code must retain the above copyright
10
+ # notice, this list of conditions and the following disclaimer.
11
+ # * Redistributions in binary form must reproduce the above copyright
12
+ # notice, this list of conditions and the following disclaimer in the
13
+ # documentation and/or other materials provided with the distribution.
14
+ # * Neither the name of the copyright holder nor the
15
+ # names of its contributors may be used to endorse or promote products
16
+ # derived from this software without specific prior written permission.
17
+
18
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19
+ # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20
+ # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21
+ # DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
22
+ # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23
+ # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24
+ # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25
+ # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26
+ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27
+ # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
19
28
  #
20
29
  # == Other Sources
21
- #
22
- # * Code of several Ruby engines came from statistics2.rb,
30
+ #
31
+ # * Code of several Ruby engines came from statistics2.rb,
23
32
  # created by Shin-ichiro HARA(sinara@blade.nagaokaut.ac.jp).
24
33
  # Retrieve from http://blade.nagaokaut.ac.jp/~sinara/ruby/math/statistics2/
25
34
  # * Code of Beta and Gamma distribution came from GSL project.
26
35
  # Ported by John O. Woods
27
36
  # Specific notices will be placed where there are appropiate
28
- #
29
- if !respond_to? :define_singleton_method
30
- class Module
31
- public :define_method
32
- end
37
+ #
33
38
 
34
- class Object
35
- def define_singleton_method(name,&block)
36
- sc=class <<self;self;end
37
- sc.define_method(name,&block)
38
- end
39
- end
40
- end
41
39
  require 'distribution/math_extension'
42
-
40
+ require 'distribution/shorthand'
41
+ require 'distribution/distributable'
42
+ require 'distribution/version'
43
43
 
44
44
  # Several distributions modules to calculate pdf, cdf, inverse cdf and generate
45
45
  # pseudo-random numbers for several statistical distributions
46
- #
46
+ #
47
47
  # == Usage:
48
48
  # Distribution::Normal.cdf(1.96)
49
49
  # => 0.97500210485178
50
50
  # Distribution::Normal.p_value(0.95)
51
51
  # => 1.64485364660836
52
52
  module Distribution
53
- VERSION="0.6.0"
54
-
55
- module Shorthand
56
- EQUIVALENCES={:p_value=>:p, :cdf=>:cdf, :pdf=>:pdf, :rng=>:r, :exact_pdf=>:epdf, :exact_cdf=>:ecdf, :exact_p_value=>:ep}
57
- def self.add_shortcut(sh,m, &block)
58
- if EQUIVALENCES.include? m.to_sym
59
- sh_name=sh+"_#{m}"
60
- define_method(sh_name,&block)
61
- sh_name=sh+"_#{EQUIVALENCES[m.to_sym]}"
62
- define_method(sh_name,&block)
63
-
64
- end
65
- end
66
- end
67
-
68
-
69
53
  SQ2PI = Math.sqrt(2 * Math::PI)
70
54
 
71
- # Create a method 'has_<library>' on Module
72
- # which require a library and return true or false
73
- # according to success of failure
74
- def self.create_has_library(library) #:nodoc:
75
- define_singleton_method("has_#{library}?") do
76
- cv="@@#{library}"
77
- if !class_variable_defined? cv
78
- begin
79
- require library.to_s
80
- class_variable_set(cv, true)
81
- rescue LoadError
82
- class_variable_set(cv, false)
55
+ class << self
56
+ # Create a method 'has_<library>' on Module
57
+ # which require a library and return true or false
58
+ # according to success of failure
59
+ def create_has_library(library) #:nodoc:
60
+ define_singleton_method("has_#{library}?") do
61
+ cv = "@@#{library}"
62
+ unless class_variable_defined? cv
63
+ begin
64
+ require library.to_s
65
+ class_variable_set(cv, true)
66
+ rescue LoadError
67
+ class_variable_set(cv, false)
68
+ end
83
69
  end
70
+ class_variable_get(cv)
84
71
  end
85
- class_variable_get(cv)
72
+ end
73
+
74
+ # Retrieves the libraries used to calculate
75
+ # distributions
76
+ def libraries_order
77
+ order = [:Ruby_]
78
+ order.unshift(:Statistics2_) if has_statistics2?
79
+ order.unshift(:GSL_) if has_gsl?
80
+ order.unshift(:Java_) if has_java?
81
+ order
82
+ end
83
+
84
+ def init_java
85
+ $LOAD_PATH.unshift File.expand_path('../../vendor/java', __FILE__)
86
+ require 'commons-math-2.2.jar'
87
+ java_import 'org.apache.commons.math.distribution.NormalDistributionImpl'
88
+ java_import 'org.apache.commons.math.distribution.PoissonDistributionImpl'
86
89
  end
87
90
  end
88
- # Retrieves the libraries used to calculate
89
- # distributions
90
- def self.libraries_order
91
- order=[:Ruby_]
92
- order.unshift(:Statistics2_) if has_statistics2?
93
- order.unshift(:GSL_) if has_gsl?
94
- order.unshift(:Java_) if has_java?
95
- order
96
- end
91
+
97
92
  create_has_library :gsl
98
93
  create_has_library :statistics2
99
94
  create_has_library :java
100
-
101
- # Magic module
102
- module Distributable #:nodoc:
103
- # Create methods for each module and add methods to
104
- # Distribution::Shorthand.
105
- #
106
- # Traverse Distribution.libraries_order adding
107
- # methods availables for each engine module on
108
- # the current library
109
- #
110
- # Kids: Metaprogramming trickery! Don't do at work.
111
- # This section was created between a very long reunion
112
- # and a 456 Km. travel
113
- def create_distribution_methods()
114
-
115
- Distribution.libraries_order.each do |l_name|
116
- if const_defined? l_name
117
- l =const_get(l_name)
118
- # Add methods from engine to base base, if not yet included
119
- l.singleton_methods.each do |m|
120
- if !singleton_methods.include? m
121
- define_method(m) do |*args|
122
- l.send(m,*args)
123
- end
124
- # Add method to Distribution::Shorthand
125
- sh=const_get(:SHORTHAND)
126
- Distribution::Shorthand.add_shortcut(sh,m) do |*args|
127
- l.send(m,*args)
128
- end
129
-
130
- module_function m
131
- end
132
- end
133
- end
134
-
135
- end
136
- # create alias for common methods
137
- alias_method :inverse_cdf, :p_value if singleton_methods.include? :p_value
138
- end
139
95
 
140
- end
96
+ require 'distribution/normal'
97
+ require 'distribution/chisquare'
98
+ require 'distribution/gamma'
99
+ require 'distribution/beta'
100
+ require 'distribution/t'
101
+ require 'distribution/f'
102
+ require 'distribution/bivariatenormal'
103
+ require 'distribution/binomial'
104
+ require 'distribution/hypergeometric'
105
+ require 'distribution/exponential'
106
+ require 'distribution/poisson'
107
+ require 'distribution/logistic'
108
+ require 'distribution/lognormal'
109
+ require 'distribution/weibull'
141
110
 
142
- autoload(:Normal, 'distribution/normal')
143
- autoload(:ChiSquare, 'distribution/chisquare')
144
- autoload(:Gamma, 'distribution/gamma')
145
- autoload(:Beta, 'distribution/beta')
146
- autoload(:T, 'distribution/t')
147
- autoload(:F, 'distribution/f')
148
- autoload(:BivariateNormal, 'distribution/bivariatenormal')
149
- autoload(:Binomial, 'distribution/binomial')
150
- autoload(:Hypergeometric, 'distribution/hypergeometric')
151
- autoload(:Exponential, 'distribution/exponential')
152
- autoload(:Poisson, 'distribution/poisson')
153
- autoload(:Logistic, 'distribution/logistic')
111
+ init_java if has_java?
154
112
  end
155
-
156
-
157
-