public void LeastSquares() { //Can't correlate with only a single datapoint if (dataSet.Count <= 1) { return; } //Reset function values m = 0f; b = 0f; nom = 0f; den = 0f; x_bar = XBar(); y_bar = YBar(); //Calculate nominator and denominator for m for (int i = 0; i < dataSet.Count; i++) { nom += (dataSet[i].x - x_bar) * (dataSet[i].y - y_bar); den += Mathf.Pow((dataSet[i].x - x_bar), 2); } m = nom / den; b = y_bar - m * x_bar; DrawOLS(); text.UpdateText(m, b); }
void StoreData() { walkRate = 5f / energyToWalk * 100f; reproRate = 50f / energyToReproduce * 100f; // != null) TextUpdate.UpdateText(myGeneration, stepsTaken, walkRate, reproRate, energyToWalk, energyToReproduce); }