Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private double Pearson(ObiektDecyzyjny a, ObiektDecyzyjny b)
- {
- double x1 = 0.00;
- double y1 = 0.00;
- for (var i = 0; i < a.deskryptory.Count(); i++)
- {
- x1 += a.deskryptory[i].wartosc;
- y1 += b.deskryptory[i].wartosc;
- }
- x1 = x1 / a.deskryptory.Count();
- y1 = y1 / b.deskryptory.Count();
- double x2 = 0.00;
- double y2 = 0.00;
- for (var i = 0; i < a.deskryptory.Count(); i++)
- {
- x2 += Math.Pow(a.deskryptory[i].wartosc - x1, 2);
- y2 += Math.Pow(b.deskryptory[i].wartosc - y1, 2);
- }
- x2 = Math.Sqrt(x2 / a.deskryptory.Count());
- y2 = Math.Sqrt(y2 / b.deskryptory.Count());
- double r = 0.00;
- for (var i = 0; i < a.deskryptory.Count(); i++)
- {
- r += ((a.deskryptory[i].wartosc - x1) / x2) * ((b.deskryptory[i].wartosc - y1) / y2);
- }
- r = r / a.deskryptory.Count();
- double d = 0;
- d = 1 - (Math.Abs(r));
- return d;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement