mysql - Need Help to understand math on how to draw liner trendline in php -
i going through first answer on how calculate trendline graph?. answer says
given trendline straight, find slope choosing 2 points , calculating:
(a) slope = (y1-y2)/(x1-x2)
then need find offset line. line specified equation:
(b) y = offset + slope*x
so need solve offset. pick point on line, , solve offset:
(c) offset = y/(slope*x)
i'm pathetic in math. need understand equation in programming term. lets have stock data containing date, open, high low, close , volume. if not wrong have calculate x axis first per answer calculate trendline when x-axis uses dates use mysql query calculate x1-x2( assuming difference between first , last date). , y axis last low price - first low price (still assuming). in next stage i'm stuck. how calculate x or offset , on third y? can please me understand it?
Comments
Post a Comment