#include #include #include #include #include "Main_datatypes.h" #include "linear_reg.h" // Array for linear regression computation // Cantidades 10b 100b 1Kb 5Kb 10Kb 50Kb 100Kb 500Kb 1Mb 10Mb 100Mb double LR_bytes_array[LR_ARRAY_TAM] = {10, 100, 1000, 5000,10000, 50000,100000, 500000, 1000000, 10000000, 100000000}; // 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(int tam, double *array, double *avg, double *diffs); /* * Computes and returns the related Y value to a given linear regression */ void lr_calc_Y(double slope, double intercept, double x_value, int *y_result) { *y_result = (int) ceil(intercept + slope * x_value); } /* * 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(int tam, double *bytes, double *times, double *slope, double *intercept) { int i; double avgX, avgY; double *diffsX, *diffsY; double SSxx, SSxy; diffsX = malloc(tam * sizeof(double)); diffsY = malloc(tam * sizeof(double)); SSxx = SSxy = 0; lr_avg_plus_diff(tam, times, &avgX, diffsX); lr_avg_plus_diff(tam, bytes, &avgY, diffsY); for(i=0; i