test/test_statistics.rb in statsample-1.5.0 vs test/test_statistics.rb in statsample-2.0.0

- old
+ new

@@ -30,11 +30,11 @@ assert(!'a10'.is_number?) assert(!''.is_number?) end def test_estimation_mean - v = ([42] * 23 + [41] * 4 + [36] * 1 + [32] * 1 + [29] * 1 + [27] * 2 + [23] * 1 + [19] * 1 + [16] * 2 + [15] * 2 + [14, 11, 10, 9, 7] + [6] * 3 + [5] * 2 + [4, 3]).to_vector(:numeric) + v = Daru::Vector.new([42] * 23 + [41] * 4 + [36] * 1 + [32] * 1 + [29] * 1 + [27] * 2 + [23] * 1 + [19] * 1 + [16] * 2 + [15] * 2 + [14, 11, 10, 9, 7] + [6] * 3 + [5] * 2 + [4, 3]) assert_equal(50, v.size) assert_equal(1471, v.sum) # limits=Statsample::SRS.mean_confidence_interval_z(v.mean(), v.sds(), v.size,676,0.80) end @@ -53,22 +53,12 @@ l = Statsample::SRS.proportion_confidence_interval_z(prop, sam, pop, a) assert_in_delta(0.28, l[0], 0.01) assert_in_delta(0.46, l[1], 0.01) end - def test_ml - if true - # real=[1,1,1,1].to_vector(:numeric) - - # pred=[0.0001,0.0001,0.0001,0.0001].to_vector(:numeric) - # puts Statsample::Bivariate.maximum_likehood_dichotomic(pred,real) - - end - end - def test_simple_linear_regression - a = [1, 2, 3, 4, 5, 6].to_vector(:numeric) - b = [6, 2, 4, 10, 12, 8].to_vector(:numeric) + a = Daru::Vector.new([1, 2, 3, 4, 5, 6]) + b = Daru::Vector.new([6, 2, 4, 10, 12, 8]) reg = Statsample::Regression::Simple.new_from_vectors(a, b) assert_in_delta((reg.ssr + reg.sse).to_f, reg.sst, 0.001) assert_in_delta(Statsample::Bivariate.pearson(a, b), reg.r, 0.001) assert_in_delta(2.4, reg.a, 0.01) assert_in_delta(1.314, reg.b, 0.001)