Module: Distribution

Defined in:
lib/distribution.rb,
lib/distribution/f.rb,
lib/distribution/t.rb,
lib/distribution/beta.rb,
lib/distribution/f/gsl.rb,
lib/distribution/gamma.rb,
lib/distribution/t/gsl.rb,
lib/distribution/f/java.rb,
lib/distribution/f/ruby.rb,
lib/distribution/normal.rb,
lib/distribution/t/java.rb,
lib/distribution/t/ruby.rb,
lib/distribution/poisson.rb,
lib/distribution/uniform.rb,
lib/distribution/version.rb,
lib/distribution/weibull.rb,
lib/distribution/beta/gsl.rb,
lib/distribution/binomial.rb,
lib/distribution/logistic.rb,
lib/distribution/beta/java.rb,
lib/distribution/beta/ruby.rb,
lib/distribution/chisquare.rb,
lib/distribution/gamma/gsl.rb,
lib/distribution/lognormal.rb,
lib/distribution/shorthand.rb,
lib/distribution/gamma/java.rb,
lib/distribution/gamma/ruby.rb,
lib/distribution/normal/gsl.rb,
lib/distribution/exponential.rb,
lib/distribution/normal/java.rb,
lib/distribution/normal/ruby.rb,
lib/distribution/poisson/gsl.rb,
lib/distribution/uniform/gsl.rb,
lib/distribution/weibull/gsl.rb,
lib/distribution/binomial/gsl.rb,
lib/distribution/poisson/java.rb,
lib/distribution/poisson/ruby.rb,
lib/distribution/uniform/ruby.rb,
lib/distribution/weibull/ruby.rb,
lib/distribution/binomial/java.rb,
lib/distribution/binomial/ruby.rb,
lib/distribution/chisquare/gsl.rb,
lib/distribution/distributable.rb,
lib/distribution/f/statistics2.rb,
lib/distribution/logistic/ruby.rb,
lib/distribution/lognormal/gsl.rb,
lib/distribution/t/statistics2.rb,
lib/distribution/chisquare/java.rb,
lib/distribution/chisquare/ruby.rb,
lib/distribution/hypergeometric.rb,
lib/distribution/lognormal/ruby.rb,
lib/distribution/math_extension.rb,
lib/distribution/bivariatenormal.rb,
lib/distribution/exponential/gsl.rb,
lib/distribution/exponential/ruby.rb,
lib/distribution/hypergeometric/gsl.rb,
lib/distribution/normal/statistics2.rb,
lib/distribution/normalmultivariate.rb,
lib/distribution/bivariatenormal/gsl.rb,
lib/distribution/hypergeometric/java.rb,
lib/distribution/hypergeometric/ruby.rb,
lib/distribution/math_extension/erfc.rb,
lib/distribution/bivariatenormal/java.rb,
lib/distribution/bivariatenormal/ruby.rb,
lib/distribution/chisquare/statistics2.rb,
lib/distribution/math_extension/gammastar.rb,
lib/distribution/math_extension/gsl_utilities.rb,
lib/distribution/math_extension/log_utilities.rb,
lib/distribution/math_extension/incomplete_beta.rb,
lib/distribution/math_extension/chebyshev_series.rb,
lib/distribution/math_extension/incomplete_gamma.rb,
lib/distribution/math_extension/exponential_integral.rb

Overview

require "statsample"

Defined Under Namespace

Modules: Beta, Binomial, BivariateNormal, ChiSquare, Distributable, Exponential, F, Gamma, Hypergeometric, LogNormal, Logistic, MathExtension, Normal, NormalMultivariate, Poisson, Shorthand, T, Uniform, Weibull

Constant Summary collapse

SQ2PI =
Math.sqrt(2 * Math::PI)
VERSION =
'0.8.0'

Class Method Summary collapse

Class Method Details

.create_has_library(library) ⇒ Object

Create a method 'has_' on Module which require a library and return true or false according to success of failure



59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/distribution.rb', line 59

def create_has_library(library) #:nodoc:
  define_singleton_method("has_#{library}?") do
    cv = "@@#{library}"
    unless class_variable_defined? cv
      begin
        require library.to_s
        class_variable_set(cv, true)
      rescue LoadError
        class_variable_set(cv, false)
      end
    end
    class_variable_get(cv)
  end
end

.init_javaObject



84
85
86
87
88
89
# File 'lib/distribution.rb', line 84

def init_java
  $LOAD_PATH.unshift File.expand_path('../../vendor/java', __FILE__)
  require 'commons-math-2.2.jar'
  java_import 'org.apache.commons.math.distribution.NormalDistributionImpl'
  java_import 'org.apache.commons.math.distribution.PoissonDistributionImpl'
end

.libraries_orderObject

Retrieves the libraries used to calculate distributions



76
77
78
79
80
81
82
# File 'lib/distribution.rb', line 76

def libraries_order
  order = [:Ruby_]
  order.unshift(:Statistics2_) if has_statistics2?
  order.unshift(:GSL_) if has_gsl?
  order.unshift(:Java_) if has_java?
  order
end