Class: Num4TstStatistic2Lib::ParametrixTestLib

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

Instance Method Summary collapse

Constructor Details

#initialize(hypothTest3) ⇒ ParametrixTestLib

Returns a new instance of ParametrixTestLib.



7
8
9
10
# File 'lib/num4tststatistic2.rb', line 7

def initialize(hypothTest3)
    @hypothTest3 = hypothTest3
    @paraTest = Num4TstStatisticLib::ParametrixTestLib.new
end

Instance Method Details

#diffPopulationMean(xi1, xi2, a) ⇒ boolean

対応のある2つの母平均の差の検定量

Examples:

xi1 = [37.1, 36.2, 36.6, 37.4, 36.8, 36.7, 36.9, 37.4, 36.6, 36.7]
xi2 = [36.8, 36.6, 36.5, 37.0, 36.0, 36.5, 36.6, 37.1, 36.4, 36.7]
hypothTest = Num4HypothTestLib::TwoSideTestLib.new
paraTest = Num4TstStatistic2Lib::ParametrixTestLib.new(hypothTest)
paraTest.diffPopulationMean(xi1, xi2, 0.05)
=> true

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

Parameters:

  • xi1 (Array)

    x1のデータ(double[])

  • xi2 (Array)

    x2のデータ(double[])

  • a (double)

    有意水準

Returns:

  • (boolean)

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



121
122
123
124
125
126
# File 'lib/num4tststatistic2.rb', line 121

def diffPopulationMean(xi1, xi2, a)
    n = xi1.size
    df = n - 1
    statistic = @paraTest.diffPopulationMean(xi1, xi2)
    return @hypothTest3.tDistTest(statistic, df, a)
end

#diffPopulationMean2EquVar(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
paraTest = Num4TstStatistic2Lib::ParametrixTestLib.new(hypothTest)
paraTest.diffPopulationMean2EquVar(xi1, xi2, 0.05)
=> false

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

Parameters:

  • xi1 (Array)

    x1のデータ(double[])

  • xi2 (Array)

    x2のデータ(double[])

  • a (double)

    有意水準

Returns:

  • (boolean)

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



80
81
82
83
84
85
86
# File 'lib/num4tststatistic2.rb', line 80

def diffPopulationMean2EquVar(xi1, xi2, a)
    n1 = xi1.size
    n2 = xi2.size
    df = n1 + n2 - 2
    statistic = @paraTest.diffPopulationMean2EquVar(xi1, xi2)
    return @hypothTest3.tDistTest(statistic, df, a)
end

#diffPopulationMean2UnEquVar(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
paraTest = Num4TstStatistic2Lib::ParametrixTestLib.new(hypothTest)
paraTest.diffPopulationMean2UnEquVar(xi1, xi2, 0.05)
=> false

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

Parameters:

  • xi1 (Array)

    x1のデータ(double[])

  • xi2 (Array)

    x2のデータ(double[])

  • a (double)

    有意水準

Returns:

  • (boolean)

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



102
103
104
105
106
# File 'lib/num4tststatistic2.rb', line 102

def diffPopulationMean2UnEquVar(xi1, xi2, a)
    df = @paraTest.df4welch(xi1, xi2)
    statistic = @paraTest.diffPopulationMean2UnEquVar(xi1, xi2)
    return @hypothTest3.tDistTest(statistic, df, a)
end

#diffPopulationRatio(m1, n1, m2, n2, a) ⇒ boolean

2つの母比率の差の検定量

Examples:

hypothTest = Num4HypothTestLib::TwoSideTestLib.new
paraTest = Num4TstStatistic2Lib::ParametrixTestLib.new(hypothTest)
paraTest.diffPopulationRatio(469, 1200, 308, 900, 0.05)
=> true

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

Parameters:

  • m1 (int)

    m1値

  • n1 (int)

    N1値

  • m2 (int)

    m2値

  • n2 (int)

    N2値

  • a (double)

    有意水準

Returns:

  • (boolean)

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



161
162
163
164
# File 'lib/num4tststatistic2.rb', line 161

def diffPopulationRatio(m1, n1, m2, n2, a)
    statistic = @paraTest.diffPopulationRatio(m1, n1, m2, n2)
    return @hypothTest3.normDistTest(statistic, a)
end

#diffPopulationVar(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
paraTest = Num4TstStatistic2Lib::ParametrixTestLib.new(hypothTest)
paraTest.diffPopulationVar(xi1, xi2, 0.05)
=> false

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

Parameters:

  • xi1 (Array)

    x1のデータ(double[])

  • xi2 (Array)

    x2のデータ(double[])

  • a (double)

    有意水準

Returns:

  • (boolean)

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



141
142
143
144
145
146
# File 'lib/num4tststatistic2.rb', line 141

def diffPopulationVar(xi1, xi2, a)
    nf = xi1.size - 1
    df = xi2.size - 1
    statistic = @paraTest.diffPopulationVar(xi1, xi2)
    return @hypothTest3.fDistTest(statistic, nf, df, a)
end

#fidelity(fi, pi, a) ⇒ boolean

適合度の検定量

Examples:

fi = [57, 33, 46, 14]
pi = [0.4, 0.2, 0.3, 0.1]
hypothTest = Num4HypothTestLib::TwoSideTestLib.new
paraTest = Num4TstStatistic2Lib::ParametrixTestLib.new(hypothTest)
paraTest.fidelity(fi, pi, 0.05)
=> false

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

Parameters:

  • fi (Array)

    実測度数(double[])

  • pi (Array)

    比率(double[])

  • a (double)

    有意水準

Returns:

  • (boolean)

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



179
180
181
182
183
# File 'lib/num4tststatistic2.rb', line 179

def fidelity(fi, pi, a)
    df = fi.size - 1
    statistic = @paraTest.fidelity(fi, pi)
    return @hypothTest3.chi2DistTest(statistic, df, a)
end

#independency(fij, a) ⇒ boolean

独立性の検定量

Examples:

fij = [
  [57, 33, 46, 14],
  [89, 24, 75, 12],
]
hypothTest = Num4HypothTestLib::TwoSideTestLib.new
paraTest = Num4TstStatistic2Lib::ParametrixTestLib.new(hypothTest)
paraTest.independency(fij, 0.05)
=> true

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

Parameters:

Returns:

  • (boolean)

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



199
200
201
202
203
204
205
# File 'lib/num4tststatistic2.rb', line 199

def independency(fij, a)
    m = fij.size
    n = fij[0].size
    df = (m - 1) * (n - 1)
    statistic = @paraTest.independency(fij)
    return @hypothTest3.chi2DistTest(statistic, df, a)
end

#populationMean(xi, m0, a) ⇒ boolean

正規母集団の母平均の検定

Examples:

hypothTest = Num4HypothTestLib::TwoSideTestLib.new
xi = [15.5, 15.7, 15.4, 15.4, 15.6, 15.4, 15.6, 15.5, 15.4]
paraTest = Num4TstStatisticLib::ParametrixTestLib.new(hypothTest)
paraTest.populationMean(xi, 15.4, 0.05)
=> true

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

Parameters:

  • xi (Array)

    データ(double[])

  • m0 (double)

    母平均

  • a (double)

    有意水準

Returns:

  • (boolean)

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



24
25
26
27
28
# File 'lib/num4tststatistic2.rb', line 24

def populationMean(xi, m0, a)
    df = xi.size - 1
    statistic = @paraTest.populationMean(xi, m0)
    return @hypothTest3.tDistTest(statistic, df, a)
end

#populationRatio(m, n, p0, a) ⇒ boolean

母比率の検定量

Examples:

hypothTest = Num4HypothTestLib::TwoSideTestLib.new
paraTest = Num4TstStatistic2Lib::ParametrixTestLib.new(hypothTest)
paraTest.populationRatio(29, 346, 0.12, 0.05)
=> true

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

Parameters:

  • m (int)

    m値

  • n (int)

    N値

  • p0 (double)

    母比率

  • a (double)

    有意水準

Returns:

  • (boolean)

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



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

def populationRatio(m, n, p0, a)
    statistic = @paraTest.populationRatio(m, n, p0)
    return @hypothTest3.normDistTest(statistic, a)
end

#populationVar(xi, sig0, a) ⇒ boolean

正規母集団の母分散の検定

Examples:

xi = [35.2, 34.5, 34.9, 35.2, 34.8, 35.1, 34.9, 35.2, 34.9, 34.8]
sd = 0.4
hypothTest = Num4HypothTestLib::TwoSideTestLib.new
paraTest = Num4TstStatistic2Lib::ParametrixTestLib.new(hypothTest)
paraTest.populationVar(xi, sd*sd, 0.05)
=> true

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

Parameters:

  • xi (Array)

    データ(double[])

  • sig0 (double)

    母分散

  • a (double)

    有意水準

Returns:

  • (boolean)

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



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

def populationVar(xi, sig0, a)
    df = xi.size - 1
    statistic = @paraTest.populationVar(xi, sig0)
    return @hypothTest3.chi2DistTest(statistic, df, a)
end