0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Excel > INTERCEPT() > 切片の値 > webの間違い > pythonで確認 / tupleで_,_という記載

Last updated at Posted at 2016-09-06

http://excel.onushi.com/function/intercept.htm
に記載のINTERCEPT()の値。

その結果、A4には線形回帰直線の切片の値である3.2が返されます。

こちらが持っている切片を求める関数(C実装)で計算すると-3.2となる。

符号が合わない。

pythonの勉強(scipyの入門)もかねてpythonで解いてみた。
参考 http://akiyoko.hatenablog.jp/entry/2013/06/16/005946

from scipy import stats

xs = [ 5, 10, 9 ]
ys = [ 2, 7, 7 ]

slope, intercept, r_value, _, _ = stats.linregress(xs, ys)

print "slope:", slope
print "intercept:", intercept
print "r_value:", r_value
結果
Success	time: 0.15 memory: 46904 signal:0
slope: 1.07142857143
intercept: -3.2380952381
r_value: 0.981980506062

webの記載の方が間違っているのか、定義が異なるのかもしれない。
こちらのC実装関数とpythonが整合することは確認できた。

余談

python実装のslope, intercept, r_value, _, _の最後の2つ。

http://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.linregress.html
を見ると"_,_"の部分にはpvalue, stderrがtupleとして返ってくるようだ。
変数として使わない場合は_と書くのだろう。

_ is indeed a very popular choice for "a name which doesn't matter" -- it's a legal name, visually unobtrusive, etc.

しかしながらGNUのgettextでの"_"イディオムには注意が必要、とのこと。
まだ自分には関係ない点なので、この情報はここまでとする。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?