Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void Random()
- {
- double tmpRand = 0;
- double tmpRand1 = 0;
- double tmpRand2 = 0;
- double S;
- Random newRand = new Random();
- for (int i = 0; i < amount; i++)
- {
- S = 1;
- tmpRand = newRand.NextDouble();
- while (S >= 1)
- {
- tmpRand1 = newRand.NextDouble();
- tmpRand2 = newRand.NextDouble();
- S = Math.Pow((2 * tmpRand1 - 1), 2) + Math.Pow((2 * tmpRand2 - 1), 2);
- }
- if (tmpRand < cl1.P)
- {
- GetRandom(tmpRand1, tmpRand2, S, ref cl1);
- }
- else
- {
- GetRandom(tmpRand1, tmpRand2, S, ref cl2);
- }
- }
- cl1.n = cl1.mas1.Count;
- cl2.n = cl2.mas1.Count;
- cl1.oP = Convert.ToDouble(cl1.n) / Convert.ToDouble(amount);
- cl2.oP = Convert.ToDouble(cl2.n) / Convert.ToDouble(amount);
- CalcError();
- cl1.Po = Convert.ToDouble(cl1.cntPo) / Convert.ToDouble(cl1.n);
- cl2.Po = Convert.ToDouble(cl2.cntPo) / Convert.ToDouble(cl2.n);
- }
- private void GetRandom(double tmp1, double tmp2, double S, ref Class cl)
- {
- double X = (2 * tmp1 - 1) * Math.Sqrt(-2 * Math.Log(S) / S);
- double Y = (2 * tmp2 - 1) * Math.Sqrt(-2 * Math.Log(S) / S);
- X = cl.d1 * X + cl.m1;
- Y = cl.d2 * Y + cl.m2;
- cl.mas1.Add(X);
- cl.mas2.Add(Y);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement