Class: Num4TstStatistic2Lib::NonParametrixTestLib

Inherits:
Object
  • Object
show all
Defined in:
lib/num4tststatistic2.rb

Overview

ノンパラメトリック検定

Instance Method Summary collapse

Constructor Details

#initialize(hypothTest3) ⇒ NonParametrixTestLib

Returns a new instance of NonParametrixTestLib.



251
252
253
254
# File 'lib/num4tststatistic2.rb', line 251

def initialize(hypothTest3)
    @hypothTest3 = hypothTest3
    @nonParaTest = Num4TstStatisticLib::NonParametrixTestLib.new
end

Instance Method Details

#ks2test(xi1, xi2, a) ⇒ boolean

コルモゴルフ・スミルノフ検定(2標本)

Examples:

xi1 = [165, 130, 182, 178, 194, 206, 160, 122, 212, 165, 247, 195]
xi2 = [180, 180, 235, 270, 240, 285, 164, 152]
hypothTest = Num4HypothTestLib::TwoSideTestLib.new
nonParaTest = Num4TstStatistic2Lib::NonParametrixTestLib.new(hypothTest)
nonParaTest.ks2test(xi1, xi2, 0.05)
=> false

Returns 検定結果(true:棄却域内 false:棄却域外).

Parameters:

  • xi1 (Array)

    x1のデータ(double[])

  • xi2 (Array)

    x2のデータ(double[])

  • a (double)

    有意水準

Returns:

  • (boolean)

    検定結果(true:棄却域内 false:棄却域外)

Raises:

  • (TypeError)


309
310
311
312
313
# File 'lib/num4tststatistic2.rb', line 309

def ks2test(xi1, xi2, a)
    raise TypeError unless @hypothTest3.kind_of?(HypothTest3IF)

    return @nonParaTest.ks2test(xi1, xi2, a)
end

#utest(x, y, a) ⇒ boolean

マン・ホイットニーのU検定

Examples:

x = [165, 130, 182, 178, 194, 206, 160, 122, 212, 165, 247, 195]
y = [180, 180, 235, 270, 240, 285, 164, 152]
hypothTest = Num4HypothTestLib::TwoSideTestLib.new
nonParaTest = Num4TstStatistic2Lib::NonParametrixTestLib.new(hypothTest)
nonParaTest.utest(x, y, 0.05)
=> true

Returns 検定結果(true:棄却域内 false:棄却域外).

Parameters:

  • x (Array)

    xのデータ(double[])

  • y (Array)

    yのデータ(double[])

  • a (double)

    有意水準

Returns:

  • (boolean)

    検定結果(true:棄却域内 false:棄却域外)

Raises:

  • (TypeError)


269
270
271
272
273
274
# File 'lib/num4tststatistic2.rb', line 269

def utest(x, y, a)
    raise TypeError unless @hypothTest3.kind_of?(HypothTest3IF)

    statistic = @nonParaTest.utest(x, y)
    return @hypothTest3.normDistTest(statistic, a)
end

#wilcoxontest(x, y, a) ⇒ boolean

ウィルコクス符号付き順位検定

Examples:

x = [37.1, 36.2, 36.6, 37.4, 36.8, 36.7, 36.9, 37.4, 36.6, 36.7]
y = [36.8, 36.6, 36.5, 37.0, 36.0, 36.5, 36.6, 37.1, 36.4, 36.7]
hypothTest = Num4HypothTestLib::TwoSideTestLib.new
nonParaTest = Num4TstStatistic2Lib::NonParametrixTestLib.new(hypothTest)
nonParaTest.wilcoxon(x, y, 0.05)
=> true

Returns 検定結果(true:棄却域内 false:棄却域外).

Parameters:

  • x (Array)

    xのデータ(double[])

  • y (Array)

    yのデータ(double[])

  • a (double)

    有意水準

Returns:

  • (boolean)

    検定結果(true:棄却域内 false:棄却域外)

Raises:

  • (TypeError)


289
290
291
292
293
294
# File 'lib/num4tststatistic2.rb', line 289

def wilcoxon(x, y, a)
    raise TypeError unless @hypothTest3.kind_of?(HypothTest3IF)

    statistic = @nonParaTest.wilcoxon(x, y)
    return @hypothTest3.normDistTest(statistic, a)
end