fsprojects / ExcelFinancialFunctions

.NET Standard library providing the full set of financial functions from Excel.
https://fsprojects.github.io/ExcelFinancialFunctions
Other
195 stars 66 forks source link

ExcelFinancialFuctions equivalent for Percentile.Inc #15

Closed ghost closed 2 years ago

ghost commented 7 years ago

Description

Can you please let me know the ExcelFinancialFunctions equivalent for Percentile.Inc?

Repro steps

Please see steps in XL: https://support.office.com/en-us/article/PERCENTILE-INC-function-680f9539-45eb-410b-9a5e-c1355e5fe2ed

Expected behavior

Would like to get a method that does the same in the library. Please help.

Actual behavior

Don't see a function for this.

Known workarounds

I have been able to use the following in C# code successfully:

private double Percentile(double[] sequence, double excelPercentile) { Array.Sort(sequence); int N = sequence.Length; double n = (N - 1) * excelPercentile + 1; // Another method: double n = (N + 1) * excelPercentile; if (n == 1d) return sequence[0]; else if (n == N) return sequence[N - 1]; else { int k = (int)n; double d = n - k; return sequence[k - 1] + d * (sequence[k] - sequence[k - 1]); } }

Related information

luajalla commented 7 years ago

Hi @anandvadul, This function is not implemented in the library, because it wasn't a subset of "financial functions". It could be easily added if you believe it's useful. You're welcome to submit a pull request, that'd be the fastest way :)

Kind regards, Natallie

jcoliz commented 2 years ago

Hi, I am cleaning up old issues. Right, as Natallie mentions, the scope of this is the "Financial Functions" category of functions. This link provides clarifications on which those are: https://support.microsoft.com/en-us/office/excel-functions-by-category-5f91f4e9-7b42-46d2-9bd1-63f26a86c0eb