Replace nested >r r> with spread in math.statistics
parent
f8e86894a4
commit
6161d99637
|
@ -1,7 +1,7 @@
|
||||||
! Copyright (C) 2008 Doug Coleman, Michael Judge.
|
! Copyright (C) 2008 Doug Coleman, Michael Judge.
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: arrays kernel math math.analysis math.functions sequences sequences.lib
|
USING: arrays combinators kernel math math.analysis math.functions sequences
|
||||||
sorting ;
|
sequences.lib sorting ;
|
||||||
IN: math.statistics
|
IN: math.statistics
|
||||||
|
|
||||||
: mean ( seq -- n )
|
: mean ( seq -- n )
|
||||||
|
@ -63,7 +63,7 @@ IN: math.statistics
|
||||||
r sq ;
|
r sq ;
|
||||||
|
|
||||||
: least-squares ( {{x,y}...} -- alpha beta )
|
: least-squares ( {{x,y}...} -- alpha beta )
|
||||||
[r] >r >r >r >r 2dup r> r> r> r>
|
[r] { [ 2dup ] [ ] [ ] [ ] [ ] } spread
|
||||||
! stack is mean(x) mean(y) mean(x) mean(y) {x} {y} sx sy
|
! stack is mean(x) mean(y) mean(x) mean(y) {x} {y} sx sy
|
||||||
[ (r) ] 2keep ! stack is mean(x) mean(y) r sx sy
|
[ (r) ] 2keep ! stack is mean(x) mean(y) r sx sy
|
||||||
swap / * ! stack is mean(x) mean(y) beta
|
swap / * ! stack is mean(x) mean(y) beta
|
||||||
|
|
Loading…
Reference in New Issue