Sha256: 9a43a56b56d5721d26e9b37b79ff9b105a1eaf67934f4a0cf79d9d428e383ca1

Contents?: true

Size: 1.17 KB

Versions: 1

Compression:

Stored size: 1.17 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|
        expect(Distribution::Shorthand.instance_methods.map(&:to_sym)).to 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|
        expect(Distribution::Shorthand.instance_methods.map(&:to_sym)).to include(m)
      end
    end
  end

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
distribution-0.8.0 spec/shorthand_spec.rb