Full code:

```
// EXEMPLO - http://en.wikipedia.org/wiki/Simple_linear_regression
float x[11] = {0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1};
float y[11] = {1, 0.95, 0.85, 0.76, 0.71, 0.65, 0.52, 0.43, 0.32, 0.22, 0.11};
float lrCoef[2] = {0, 0};
// INICIANDO AS VARIÁVEIS
float sum_x = 0;
float sum_y = 0;
float sum_xy = 0;
float sum_xx = 0;
void setup(){
Serial.begin(9600);
delay(200);
for(int i=0; i<11; i++){
y[i]=-log10(y[i]/y[0]);
Serial.println(y[i]);
}
// CHAMA O ALGORITMO DE REGRESSÃO LINEAR
simpLinReg(x, y, lrCoef, 11);
Serial.println("Equação Linear:");
Serial.println("");
Serial.print("Abs = ");
Serial.print(lrCoef[0], 11);
if (lrCoef[1] > 0){
Serial.print("*Conc + ");
}
else{
Serial.print("*Conc ");
}
Serial.println(lrCoef[1], 4);
}
void loop(){
}
void simpLinReg(float* x, float* y, float* lrCoef, int n){
// CALCULOS PARA REGRESSÃO LINEAR
for (int i=0; i<n; i++){
sum_x += x[i];
sum_y += y[i];
sum_xy = sum_xy+x[i]*y[i];
sum_xx = sum_xx+x[i]*x[i];
}
lrCoef[0]=(n*sum_xy-sum_x*sum_y)/(n*sum_xx-sum_x*sum_x);
lrCoef[1]=(sum_y/n)-((lrCoef[0]*sum_x)/n);
}
```