#include #include #include #include "Main_datatypes.h" #include "linear_reg.h" // Linear regression // Y = a +bX // Bytes = a +b(Time) // // X is the independent variable, which correlates to the Communication time // Y is the dependent variable, which correlates to the number of bytes // void lr_avg_plus_diff(double *array, double *avg, double *diffs); /* * Computes the slope and intercept for a given array of times * so users can calculate the number of bytes for a given time. * */ void lr_compute(double *times, double *slope, double *intercept) { int i; double avgX, avgY; double *diffsX, *diffsY; double SSxx, SSxy; diffsX = malloc(LR_ARRAY_TAM * sizeof(double)); diffsY = malloc(LR_ARRAY_TAM * sizeof(double)); SSxx = SSxy = 0; lr_avg_plus_diff(times, &avgX, diffsX); lr_avg_plus_diff(LR_bytes_array, &avgY, diffsY); for(i=0; i