Created
October 11, 2010 02:10
-
-
Save nobusue/619868 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// g100pon #50 回帰分析 | |
// y = intercept + slope * x | |
// see: http://commons.apache.org/math/userguide/stat.html | |
@Grab(group='commons-math', module='commons-math', version='1.2') | |
import org.apache.commons.math.stat.regression.SimpleRegression | |
def reg = new SimpleRegression() | |
// データを1点づつ追加するパターン | |
reg.addData(1,2) | |
reg.addData(3,3) | |
reg.addData(3,3) | |
println "切片=${reg.intercept}" | |
println "傾き=${reg.slope}" | |
println "傾きの誤差=${reg.slopeStdErr}" | |
reg.clear() | |
// データをdouble[][]でまとめて追加するパターン | |
def data = [[ 1, 3], [2, 5], [3, 7], [4, 14], [5, 11]] as double[][] | |
reg.addData(data) | |
println "切片=${reg.intercept}" | |
println "傾き=${reg.slope}" | |
println "傾きの誤差=${reg.slopeStdErr}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment