Sha256: 10a8f2ee00e9fee57d964c7ab0c248a7837e96a8aae2389ce6a60f54870e9889

Contents?: true

Size: 1.25 KB

Versions: 6

Compression:

Stored size: 1.25 KB

Contents

require(File.dirname(__FILE__)+'/helpers_tests.rb')


class StatsampleTestTestCase < MiniTest::Unit::TestCase
  def test_chi_square
    real=Matrix[[95,95],[45,155]]
    expected=Matrix[[68,122],[72,128]]
    assert_nothing_raised do
      chi=Statsample::Test.chi_square(real,expected)
    end
    chi=Statsample::Test.chi_square(real,expected)
    assert_in_delta(32.53,chi,0.1)
  end
  def test_u_mannwhitney
    a=[1,2,3,4,5,6].to_scale
    b=[0,5,7,9,10,11].to_scale
    assert_equal(7.5, Statsample::Test.u_mannwhitney(a,b).u)
    assert_equal(7.5, Statsample::Test.u_mannwhitney(b,a).u)
    a=[1, 7,8,9,10,11].to_scale
    b=[2,3,4,5,6,12].to_scale
    assert_equal(11, Statsample::Test.u_mannwhitney(a,b).u)
  end


  def test_levene
    a=[1,2,3,4,5,6,7,8,100,10].to_scale
    b=[30,40,50,60,70,80,90,100,110,120].to_scale
    levene=Statsample::Test::Levene.new([a,b])
    assert_levene(levene)
  end
  def test_levene_dataset
    a=[1,2,3,4,5,6,7,8,100,10].to_scale
    b=[30,40,50,60,70,80,90,100,110,120].to_scale
    ds={'a'=>a,'b'=>b}.to_dataset
    levene=Statsample::Test::Levene.new(ds)
    assert_levene(levene)
  end
  def assert_levene(levene)
    assert_in_delta(0.778, levene.f, 0.001)
    assert_in_delta(0.389, levene.probability, 0.001)
  end
 
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
statsample-0.13.1 test/test_stest.rb
statsample-0.13.0 test/test_stest.rb
statsample-0.12.0 test/test_stest.rb
statsample-0.11.2 test/test_stest.rb
statsample-0.11.1 test/test_stest.rb
statsample-0.11.0 test/test_stest.rb