Class: CorrTestLib::CorreFactLib

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

Overview

母相関係数の検定

Instance Method Summary collapse

Constructor Details

#initialize(hypothTest3) ⇒ CorreFactLib

Returns a new instance of CorreFactLib.



69
70
71
72
# File 'lib/corrtest.rb', line 69

def initialize(hypothTest3)
    @hypothTest3 = hypothTest3
    @corr = CorrStatisticLib.new
end

Instance Method Details

#kendallscorr(x, y, rth0, a) ⇒ boolean

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

Examples:

x = [113, 64, 16, 45, 28, 19, 30, 82, 76]
y = [31, 5, 2, 17, 18, 2, 9, 25, 13]
hypothTest = Num4HypothTestLib::TwoSideTestLib.new
corrTest = CorrTestLib::CorreFactLib.new(hypothTest)
corrTest.kendallscorr(x, y, -0.3, 0.05)
=> true

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

Parameters:

  • x (Array)

    xのデータ(double[])

  • y (Array)

    yのデータ(double[])

  • rth0 (double)

    母相関係数

  • a (double)

    有意水準

Returns:

  • (boolean)

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

Raises:

  • (TypeError)


128
129
130
131
132
# File 'lib/corrtest.rb', line 128

def kendallscorr(x, y, rth0, a)
    raise TypeError unless @hypothTest3.kind_of?(HypothTest3IF)
    statistic = @corr.kendallscorr(x, y)
    return @hypothTest3.populationCorre(statistic, x.size, rth0, a)
end

#pearsoCorrelation(x, y, rth0, a) ⇒ boolean

ピアソン相関係数

Examples:

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

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

Parameters:

  • x (Array)

    xのデータ(double[])

  • y (Array)

    yのデータ(double[])

  • rth0 (double)

    母相関係数

  • a (double)

    有意水準

Returns:

  • (boolean)

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

Raises:

  • (TypeError)


88
89
90
91
92
# File 'lib/corrtest.rb', line 88

def pearsoCorrelation(x, y, rth0, a)
    raise TypeError unless @hypothTest3.kind_of?(HypothTest3IF)
    statistic = @corr.pearsoCorrelation(x, y)
    return @hypothTest3.populationCorre(statistic, x.size, rth0, a)
end

#spearmanscorr(x, y, rth0, a) ⇒ boolean

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

Examples:

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

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

Parameters:

  • x (Array)

    xのデータ(double[])

  • y (Array)

    yのデータ(double[])

  • rth0 (double)

    母相関係数

  • a (double)

    有意水準

Returns:

  • (boolean)

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

Raises:

  • (TypeError)


108
109
110
111
112
# File 'lib/corrtest.rb', line 108

def spearmanscorr(x, y, rth0, a)
    raise TypeError unless @hypothTest3.kind_of?(HypothTest3IF)
    statistic = @corr.spearmanscorr(x, y)
    return @hypothTest3.populationCorre(statistic, x.size, rth0, a)
end