Module: Distribution

Defined in:
lib/distribution.rb,
lib/distribution/t.rb,
lib/distribution/f.rb,
lib/distribution/beta.rb,
lib/distribution/gamma.rb,
lib/distribution/f/gsl.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/weibull.rb,
lib/distribution/version.rb,
lib/distribution/poisson.rb,
lib/distribution/logistic.rb,
lib/distribution/beta/gsl.rb,
lib/distribution/binomial.rb,
lib/distribution/lognormal.rb,
lib/distribution/gamma/gsl.rb,
lib/distribution/chisquare.rb,
lib/distribution/beta/java.rb,
lib/distribution/beta/ruby.rb,
lib/distribution/normal/gsl.rb,
lib/distribution/gamma/java.rb,
lib/distribution/gamma/ruby.rb,
lib/distribution/normal/java.rb,
lib/distribution/normal/ruby.rb,
lib/distribution/weibull/gsl.rb,
lib/distribution/exponential.rb,
lib/distribution/poisson/gsl.rb,
lib/distribution/weibull/ruby.rb,
lib/distribution/binomial/gsl.rb,
lib/distribution/poisson/java.rb,
lib/distribution/poisson/ruby.rb,
lib/distribution/logistic/ruby.rb,
lib/distribution/binomial/java.rb,
lib/distribution/binomial/ruby.rb,
lib/distribution/f/statistics2.rb,
lib/distribution/t/statistics2.rb,
lib/distribution/lognormal/gsl.rb,
lib/distribution/chisquare/gsl.rb,
lib/distribution/hypergeometric.rb,
lib/distribution/math_extension.rb,
lib/distribution/lognormal/ruby.rb,
lib/distribution/chisquare/java.rb,
lib/distribution/chisquare/ruby.rb,
lib/distribution/exponential/gsl.rb,
lib/distribution/bivariatenormal.rb,
lib/distribution/exponential/ruby.rb,
lib/distribution/hypergeometric/gsl.rb,
lib/distribution/normalmultivariate.rb,
lib/distribution/normal/statistics2.rb,
lib/distribution/hypergeometric/java.rb,
lib/distribution/hypergeometric/ruby.rb,
lib/distribution/bivariatenormal/gsl.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/log_utilities.rb,
lib/distribution/math_extension/gsl_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, Weibull

Constant Summary

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

Class Method Summary collapse

Class Method Details

.create_has_library(library) ⇒ Object

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



63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/distribution.rb', line 63

def self.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



130
131
132
133
134
135
# File 'lib/distribution.rb', line 130

def self.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



80
81
82
83
84
85
86
# File 'lib/distribution.rb', line 80

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