Sha256: a75ca474a64daac6ded8f2766171b9a721ac37961d7e8c59099d926653835b9c

Contents?: true

Size: 1.15 KB

Versions: 8

Compression:

Stored size: 1.15 KB

Contents

require File.expand_path(File.dirname(__FILE__)+"/spec_helper.rb")
describe Distribution::Shorthand do
  include Distribution::Shorthand
  it "should have basic methods for all distributions" do
    [:Normal,:ChiSquare, :F, :Hypergeometric, :Binomial, :T].each do |d|
      klass=Distribution.const_get(d)
      shortname=klass::SHORTHAND
      methods=[:pdf, :cdf, :p_value].map {|m| "#{shortname}_#{m}".to_sym}
      methods.each do |m| 
        Distribution::Shorthand.instance_methods.map {|v| v.to_sym}.should include(m)
      end
    end
    
  end
  it "should have exact methods discrete distributions" do
    [:Hypergeometric, :Binomial].each do |d|
      klass=Distribution.const_get(d)
      shortname=klass::SHORTHAND
      methods=[:epdf, :ecdf].map {|m| "#{shortname}_#{m}".to_sym}
      methods.each do |m| 
        Distribution::Shorthand.instance_methods.map {|v| v.to_sym}.should include(m)
      end
    end
    
  end


  it "returns same values as long form" do
    x=rand()
    norm_cdf(x).should eql(Distribution::Normal.cdf(x))
    norm_pdf(x).should eql(Distribution::Normal.pdf(x))
    norm_p_value(x).should eql(Distribution::Normal.p_value(x))
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
distribution-0.7.3 spec/shorthand_spec.rb
distribution-0.7.2 spec/shorthand_spec.rb
distribution-0.7.1 spec/shorthand_spec.rb
distribution-0.7.0 spec/shorthand_spec.rb
distribution-0.6.0 spec/shorthand_spec.rb
distribution-0.5.0 spec/shorthand_spec.rb
distribution-0.4.0 spec/shorthand_spec.rb
distribution-0.3.0 spec/shorthand_spec.rb