Skip to content

About

One pass (O(N)) descriptive statistics including variance, means, min & max and more. Can be calculated on-the-fly.

Topics

Resources

Stars

3 stars

Watchers

1 watching

Forks

Repository files navigation

OnTheFlyStats

CI NuGet version NuGet downloads Quality Gate Status Coverage License: MIT Buy Me a Coffee

One-pass (O(N)) descriptive statistics. Statistics are always ready and O(1) to retrieve — no recalculation needed.

Install

dotnet add package OnTheFlyStats

Statistics

  • Mean (arithmetic, geometric, root-mean-square)
  • Variance (population and sample)
  • Standard deviation (population and sample)
  • Standard error of the mean
  • Z-score / standard score
  • Sum, min, max
  • Range and mid-range
  • Count (N)

Usage

Instead of recalculating mean each loop iteration:

foreach (var item in populationList)
{
    averageLabel.Value = populationList.Average(); // O(N²) — never do this
    minLabel.Value = populationList.Min();
    maxLabel.Value = populationList.Max();
}

Use:

var stats = new Stats();
foreach (var item in populationList)
{
    stats.Update(item);
    averageLabel.Value = stats.Mean;
    minLabel.Value = stats.Min;
    maxLabel.Value = stats.Max;
}

Or compute from a collection in one line:

var stats = matrix[x].Stats();
var listMin = stats.Min;
var listMax = stats.Max;

Confusion Matrix

var roc = new ReceiverOperatorCharacteristic(expected, predicted);
Console.WriteLine($"Accuracy: {roc.Accuracy:P1}");
Console.WriteLine($"Sensitivity: {roc.Sensitivity:P1}");
Console.WriteLine($"Specificity: {roc.Specificity:P1}");

About

One pass (O(N)) descriptive statistics including variance, means, min & max and more. Can be calculated on-the-fly.

Topics

Resources

Stars

3 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages