This commit is contained in:
Ingy döt Net 2013-04-10 21:29:02 -07:00
parent 764da6cbbb
commit db842d013d
19005 changed files with 197040 additions and 7 deletions

View file

@ -0,0 +1,6 @@
NB. Wikipedia data
x=: 1.47 1.50 1.52 1.55 1.57 1.60 1.63 1.65 1.68 1.70 1.73 1.75 1.78 1.80 1.83
y=: 52.21 53.12 54.48 55.84 57.20 58.57 59.93 61.29 63.11 64.47 66.28 68.10 69.92 72.19 74.46
y %. x ^/ i.3 NB. calculate coefficients b1, b2 and b3 for 2nd degree polynomial
128.813 _143.162 61.9603

View file

@ -0,0 +1,12 @@
X=: x ^/ i.3 NB. form Design matrix
X=: (x^0) ,. (x^1) ,. (x^2) NB. equivalent of previous line
4{.X NB. show first 4 rows of X
1 1.47 2.1609
1 1.5 2.25
1 1.52 2.3104
1 1.55 2.4025
NB. Where y is a set of observations and X is the design matrix
NB. y %. X does matrix division and gives the regression coefficients
y %. X
128.813 _143.162 61.9603

View file

@ -0,0 +1,6 @@
mp=: +/ .* NB. matrix product
NB. %.X is matrix inverse of X
NB. |:X is transpose of X
(%.(|:X) mp X) mp (|:X) mp y
128.814 _143.163 61.9606