2017-05-01から1日間の記事一覧

最小二乗法フィッティング

サンプルデータ生成 from numpy.random import * fout = open("out.txt",'w') a = 20 b = -15 for x in range(100): y = a*x + b + normal(0,20) fout.write("{0},{1}\n".format(x,y)) fout.close() 正規方程式を解く import numpy fin = open('out.txt','r'…