You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
#include <stdbool.h>
#include <stdint.h>
#include "least_square_method.h"
void least_square_method(int xstart, int xtedp, int xend, gety_t gety, float *c, float *k) { double xi = 0, x2 = 0, yi = 0, xy = 0; int xnow = 0; int maxn = 0; for (xnow = xstart; xnow <= xend; xnow += xtedp) { xi += xnow, x2 += xnow * xnow, yi += gety(xnow), xy += xnow * gety(xnow); maxn++; } *c = (yi * x2 - xy * xi) / (x2 * maxn - xi * xi); *k = (yi * xi - xy * maxn) / (xi * xi - x2 * maxn); }
|