Calculate median in c#

前端 未结 12 1476
别跟我提以往
别跟我提以往 2020-11-29 23:35

I need to write function that will accept array of decimals and it will find the median.

Is there a function in the .net Math library?

12条回答
  •  一生所求
    2020-11-30 00:17

    Math.NET is an opensource library that offers a method for calculating the Median. The nuget package is called MathNet.Numerics.

    The usage is pretty simple:

    using MathNet.Numerics.Statistics;
    
    IEnumerable data;
    double median = data.Median();
    

提交回复
热议问题