Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
32
Task/Statistics-Basic/C-sharp/statistics-basic.cs
Normal file
32
Task/Statistics-Basic/C-sharp/statistics-basic.cs
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
using System;
|
||||
using MathNet.Numerics.Statistics;
|
||||
|
||||
class Program
|
||||
{
|
||||
static void Run(int sampleSize)
|
||||
{
|
||||
double[] X = new double[sampleSize];
|
||||
var r = new Random();
|
||||
for (int i = 0; i < sampleSize; i++)
|
||||
X[i] = r.NextDouble();
|
||||
|
||||
const int numBuckets = 10;
|
||||
var histogram = new Histogram(X, numBuckets);
|
||||
Console.WriteLine("Sample size: {0:N0}", sampleSize);
|
||||
for (int i = 0; i < numBuckets; i++)
|
||||
{
|
||||
string bar = new String('#', (int)(histogram[i].Count * 360 / sampleSize));
|
||||
Console.WriteLine(" {0:0.00} : {1}", histogram[i].LowerBound, bar);
|
||||
}
|
||||
var statistics = new DescriptiveStatistics(X);
|
||||
Console.WriteLine(" Mean: " + statistics.Mean);
|
||||
Console.WriteLine("StdDev: " + statistics.StandardDeviation);
|
||||
Console.WriteLine();
|
||||
}
|
||||
static void Main(string[] args)
|
||||
{
|
||||
Run(100);
|
||||
Run(1000);
|
||||
Run(10000);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue