问题
我希望将y = mx b等式(其中m是SLOPE,b是INTERCEPT)应用于数据集,如SQL代码所示.来自(MySQL)查询的值是:
SLOPE = 0.0276653965651912
INTERCEPT = -57.2338357550468
SQL代码
SELECT
((sum(t.YEAR) * sum(t.AMOUNT)) - (count(1) * sum(t.YEAR * t.AMOUNT))) /
(power(sum(t.YEAR), 2) - count(1) * sum(power(t.YEAR, 2))) as SLOPE,
((sum( t.YEAR ) * sum( t.YEAR * t.AMOUNT )) -
(sum( t.AMOUNT ) * sum(power(t.YEAR, 2)))) /
(power(sum(t.YEAR), 2) - count(1) * sum(power(t.YEAR, 2))) as INTERCEPT,
FROM
(SELECT
D.AMOUNT,
Y.YEAR
FROM
CITY C, STATION S, YEAR_REF Y, MONTH_REF M, DAILY D
WHERE
-- For a specific city ...
--
C.ID = 8590 AND
-- Find all the stations within a 15 unit radius ...
--
SQRT( POW( C.LATITUDE - S.LATITUDE, 2 ) + POW( C.LONGITUDE - S.LONGITUDE, 2 ) ) < 15 A