combine-regress ( regress1 regress2 -- regress3 )


Vocabulary
math.statistics.running

Inputs
regress1an object
regress2an object


Outputs
regress3an object


Definition


:: combine-regress ( regress1 regress2 -- regress3 )
regress1 regress2 [ n>> ] bi@ + dup :> n regress1 regress2
[ x-stats>> ] bi@ combine-stats regress1 regress2
[ y-stats>> ] bi@ combine-stats regress2 regress1
[ x-stats>> mean ] bi@ - :> delta-x regress2 regress1
[ y-stats>> mean ] bi@ - :> delta-y regress1 regress2
[ xy>> ] bi@ + regress1 regress2 [ n>> ] bi@ * delta-x *
delta-y * n / + running-regress boa ;