private static readonly Random Random = new Random();
private readonly double _angle;
private bool _measured = false;
public Particle(double angle)
public bool GetValue(int sensorPosition)
throw new InvalidOperationException("Измерить можно только один раз!");
return IsDetectedBySensor(sensorPosition, _angle);
private static bool IsDetectedBySensor(int sensorPosition, double angle)
probability = ComputeProbability(0 + angle);
probability = ComputeProbability(120 + angle);
probability = ComputeProbability(240 + angle);
throw new ArgumentOutOfRangeException();
if (probability >= Random.NextDouble())
private static double ComputeProbability(double angle)
var cos = Math.Cos(Math.PI / 180.0 * angle);
public class EntanglementParticles
public Particle First { get; private set; }
public Particle Second { get; private set; }
public EntanglementParticles()
var angle1 = Random.NextDouble() * 360;
var angle2 = angle1 + 90;
First = new Particle(angle1);
Second = new Particle(angle2);
public static void Main(string[] args)
private static void Experiment1()
var totalAttempts = 10000;
for (int attemptNumber = 1; attemptNumber <= totalAttempts; attemptNumber++)
var entanglementParticles = new EntanglementParticles();
int firstSensorPosition = 1;
int secondSensorPosition = 1;
bool firstValue = entanglementParticles.First.GetValue(firstSensorPosition);
bool secondValue = entanglementParticles.Second.GetValue(secondSensorPosition);
if (firstValue != secondValue)
Console.WriteLine("Эксперимент №1: {0}% значений не совпало", (decimal)disparityCount / totalAttempts * 100);
private static void Experiment2()
var totalAttempts = 10000;
for (int attemptNumber = 1; attemptNumber <= totalAttempts; attemptNumber++)
var entanglementParticles = new EntanglementParticles();
int firstSensorPosition = GetRandomInteger(1, 3);
int secondSensorPosition = GetRandomInteger(1, 3);
bool firstValue = entanglementParticles.First.GetValue(firstSensorPosition);
bool secondValue = entanglementParticles.Second.GetValue(secondSensorPosition);
if (firstValue != secondValue)
Console.WriteLine("Эксперимент №2: {0}% значений не совпало", (decimal)disparityCount / totalAttempts * 100);
private static int GetRandomInteger(int from, int to)
return Random.Next(from, to + 1);