Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
4
Task/Random-numbers/C-sharp/random-numbers-1.cs
Normal file
4
Task/Random-numbers/C-sharp/random-numbers-1.cs
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
private static double randomNormal()
|
||||
{
|
||||
return Math.Cos(2 * Math.PI * tRand.NextDouble()) * Math.Sqrt(-2 * Math.Log(tRand.NextDouble()));
|
||||
}
|
||||
27
Task/Random-numbers/C-sharp/random-numbers-2.cs
Normal file
27
Task/Random-numbers/C-sharp/random-numbers-2.cs
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
static Random tRand = new Random();
|
||||
|
||||
static void Main(string[] args)
|
||||
{
|
||||
double[] a = new double[1000];
|
||||
|
||||
double tAvg = 0;
|
||||
for (int x = 0; x < a.Length; x++)
|
||||
{
|
||||
a[x] = randomNormal() / 2 + 1;
|
||||
tAvg += a[x];
|
||||
}
|
||||
|
||||
tAvg /= a.Length;
|
||||
Console.WriteLine("Average: " + tAvg.ToString());
|
||||
|
||||
double s = 0;
|
||||
for (int x = 0; x < a.Length; x++)
|
||||
{
|
||||
s += Math.Pow((a[x] - tAvg), 2);
|
||||
}
|
||||
s = Math.Sqrt(s / 1000);
|
||||
|
||||
Console.WriteLine("Standard Deviation: " + s.ToString());
|
||||
|
||||
Console.ReadLine();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue