using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace console1 { class Program { static double[] P; //ожидаемая вероятность static double p = 3; static int i = 1; static double mathWait; static double dispers; static double sqrtVariance; static void Main(string[] args) { //кол-во сообщений int count = 5; double mathWait = getResult1(count); if(Math.Floor(mathWait) == count || Math.Ceiling(mathWait) == count) Console.WriteLine("кол-во сообщений примерно равно мат. ожиданию:\n mathWait = " + mathWait + " count = " + count); else if (count > mathWait) Console.WriteLine("кол-во сообщений больше мат. ожидания:\n mathWait = " + mathWait + " count = " + count); else Console.WriteLine("кол-во сообщений меньше мат. ожидания:\n mathWait = " + mathWait + " count = " + count); } public static double getResult1(int count) { int counter = 1; while (true) { for (int i = 0; i < counter; i++) { //мат. ожидание mathWait = i * (Math.Pow(p, i) * (1 - p)) + (i + 1) * (Math.Pow(p, i) * (1 - p)) + (i + 2) * (Math.Pow(p, i) * (1 - p)) + (i + 3) * (Math.Pow(p, i) * (1 - p)) + (i + 4) * (Math.Pow(p, i) * (1 - p)); //дисперсия dispers = Math.Pow(i, 2) * (Math.Pow(p, i) * (1 - p)) + Math.Pow((i + 1), 2) * (Math.Pow(p, i) * (1 - p)) + Math.Pow((i + 2), 2) * (Math.Pow(p, i) * (1 - p)) + Math.Pow((i + 3), 2) * (Math.Pow(p, i) * (1 - p)); //средне. квадратическое отклонение sqrtVariance = Math.Sqrt(dispers); } counter++; if (counter == count+1) break; } return mathWait; } }