Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- This Is my code. I'm getting strange results for the doubles.
- #include <iostream>
- using namespace std;
- double product = 0;
- double sumxy = 0;
- double sumx = 0;
- double sumy = 0;
- void LLParams(const double x[], const double y[], int n, double &m, double &b)
- {
- for (int i = 0; i <= n; i++)
- {
- product = x[i] * y[i];
- sumxy = sumxy + product;
- sumx = sumx + x[i];
- sumy = sumy + y[i];
- }
- {
- m = ((n*sumxy) - (sumx*sumy)) / ((n*sumx*sumx) - (sumx*sumx));
- b = (sumy - m*sumx) / n;
- cout << sumxy << " " << sumx << " " << sumy << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement