Class: Num4RegAnaLib::SmplRegAnaLib

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

Overview

単回帰分析

Instance Method Summary collapse

Constructor Details

#initializeSmplRegAnaLib

Returns a new instance of SmplRegAnaLib.



12
13
14
# File 'lib/num4regana.rb', line 12

def initialize
    @regana = SmplRegAna.getInstance()
end

Instance Method Details

#getr(yi, xi) ⇒ double

相関係数

Examples:

yi = [286, 851, 589, 389, 158, 1037, 463, 563, 372, 1020]
xi = [107, 336, 233,  82,  61,  378, 129, 313, 142,  428]
regana = Num4RegAnaLib::SmplRegAnaLib.new
regana.getr(yi, xi)
=> 0.945

Returns 決定係数.

Parameters:

  • yi (Array)

    yの値(double[])

  • xi (Array)

    xの値(double[])

Returns:

  • (double)

    決定係数



66
67
68
# File 'lib/num4regana.rb', line 66

def getr(yi, xi)
    return @regana.getR(yi.to_java(Java::double), xi.to_java(Java::double))
end

#getr2(yi, xi) ⇒ double

決定係数

Examples:

yi = [286, 851, 589, 389, 158, 1037, 463, 563, 372, 1020]
xi = [107, 336, 233,  82,  61,  378, 129, 313, 142,  428]
regana = Num4RegAnaLib::SmplRegAnaLib.new
regana.getr2(yi, xi)
=> 0.893

Returns 決定係数.

Parameters:

  • yi (Array)

    yの値(double[])

  • xi (Array)

    xの値(double[])

Returns:

  • (double)

    決定係数



51
52
53
# File 'lib/num4regana.rb', line 51

def getr2(yi, xi)
    return @regana.getR2(yi.to_java(Java::double), xi.to_java(Java::double))
end

#line_reg_ana(yi, xi) ⇒ Hash

単回帰分析

Examples:

yi = [286, 851, 589, 389, 158, 1037, 463, 563, 372, 1020]
xi = [107, 336, 233,  82,  61,  378, 129, 313, 142,  428]
regana = Num4RegAnaLib::SmplRegAnaLib.new
regana.line_reg_ana(yi, xi)
=> 
  {
     "intercept":  99.075, # 定数項
     "slope":      2.145,  # 回帰係数
  }

Returns (intercept:定数項 slope:回帰係数).

Parameters:

  • yi (Array)

    yの値(double[])

  • xi (Array)

    xの値(double[])

Returns:

  • (Hash)

    (intercept:定数項 slope:回帰係数)



31
32
33
34
35
36
37
38
# File 'lib/num4regana.rb', line 31

def line_reg_ana(yi, xi)
    ret = @regana.lineRegAna(yi.to_java(Java::double), xi.to_java(Java::double))
    retRb = {
        "intercept":  ret.getIntercept(), # 定数項
        "slope":      ret.getSlope(),     # 回帰係数
    }
    return retRb
end