Class: CorrTestLib::DecorrTestLib

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

Overview

無相関の検定

Instance Method Summary collapse

Constructor Details

#initializeDecorrTestLib

Returns a new instance of DecorrTestLib.



8
9
10
11
# File 'lib/corrtest.rb', line 8

def initialize
    @corr = CorrStatisticLib.new
    @hypothTest = Num4HypothTestLib::DecorrTestLib.new
end

Instance Method Details

#kendallscorr(x, y, a) ⇒ boolean

ケンドールの順位相関係数

Examples:

x = [113, 64, 16, 45, 28, 19, 30, 82, 76]
y = [31, 5, 2, 17, 18, 2, 9, 25, 13]
corrTest = CorrTestLib::DecorrTestLib.new
corrTest.kendallscorr(x, y, 0.05)
=> false

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

Parameters:

  • x (Array)

    xのデータ(double[])

  • y (Array)

    yのデータ(double[])

  • a (double)

    有意水準

Returns:

  • (boolean)

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



61
62
63
64
65
# File 'lib/corrtest.rb', line 61

def kendallscorr(x, y, a)
    df = x.size - 2
    statistic = @corr.kendallscorr(x, y)
    return @hypothTest.twoSideTest(statistic, df, a)
end

#pearsoCorrelation(x, y, a) ⇒ boolean

ピアソン相関係数

Examples:

x = [113, 64, 16, 45, 28, 19, 30, 82, 76]
y = [31, 5, 2, 17, 18, 2, 9, 25, 13]
corrTest = CorrTestLib::DecorrTestLib.new
corrTest.pearsoCorrelation(x, y, 0.05)
=> true

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

Parameters:

  • x (Array)

    xのデータ(double[])

  • y (Array)

    yのデータ(double[])

  • a (double)

    有意水準

Returns:

  • (boolean)

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



25
26
27
28
29
# File 'lib/corrtest.rb', line 25

def pearsoCorrelation(x, y, a)
    df = x.size - 2
    statistic = @corr.pearsoCorrelation(x, y)
    return @hypothTest.twoSideTest(statistic, df, a)
end

#spearmanscorr(x, y, a) ⇒ boolean

スピアマンの順位相関係数

Examples:

x = [113, 64, 16, 45, 28, 19, 30, 82, 76]
y = [31, 5, 2, 17, 18, 2, 9, 25, 13]
corrTest = CorrTestLib::DecorrTestLib.new
corrTest.spearmanscorr(x, y, 0.05)
=> true

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

Parameters:

  • x (Array)

    xのデータ(double[])

  • y (Array)

    yのデータ(double[])

  • a (double)

    有意水準

Returns:

  • (boolean)

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



43
44
45
46
47
# File 'lib/corrtest.rb', line 43

def spearmanscorr(x, y, a)
    df = x.size - 2
    statistic = @corr.spearmanscorr(x, y)
    return @hypothTest.twoSideTest(statistic, df, a)
end