Skip to content

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

License

Notifications You must be signed in to change notification settings

PFalkowski/OnTheFlyStats

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

48 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OnTheFlyStats

NuGet version (OnTheFlyStats) Licence (OnTheFlyStats)

One pass (O(N)) descriptive statistics including:

  • variance
  • means (arithmetic, geometric and RootMeanSquare)
  • sum, min & max
  • sample and population variance
  • standard deviation of sample and population
  • Range and mid range
  • Count (N)

Instead of writing:

var listMin = matrix[x].Min(); // TODO: calculate in one go
var listMax = matrix[x].Max(); // TODO: calculate in one go

Use:

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

Instead of recalculating mean each time the loop updates:

foreach (var item in populationList)
{
    averageLabel.Value = populationList.Average(); // O(N * N) overhead, never write code like this
    minLabel.Value = populationList.Min(); // O(N * N) overhead, never write code like this
    maxLabel.Value = populationList.Max(); // O(N * N) overhead, never write code like this
}

Use:

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

About

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

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages