Showing posts with label statistics. Show all posts
Showing posts with label statistics. Show all posts

Sunday, October 6, 2024

Extract line count of file at each git revision

git rev-list --reverse HEAD -- words.csv | \
    xargs -I {} sh -c 'echo $(git show -s --date=short --format="%ad" {}) $(git show {}:./words.csv | wc -l)'

Thursday, June 28, 2012

Calculate the exponential moving average of a stream of numbers

public static IEnumerable<double> ExponentialMovingAverage(this IEnumerable<double> source, double alpha)
{
    double? last = null;
    return source.Select(
        value =>
        {
            var average = last != null ? alpha*value + (1 - alpha)*last.Value : value;
            last = average;
            return average;
        });
}