We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
See: https://en.wikipedia.org/wiki/Percentile#The_weighted_percentile_method
My current code is as follows. But I don't know how to support weighted percentile?
func TestPercentile(t *testing.T) { values := []float64{4, 5, 3, 1, 2} percentiles := []float64{} for i := 1; i <= 100; i++ { percentile, err := stats.PercentileNearestRank(values, float64(i)) if err != nil { panic(err) } percentiles = append(percentiles, percentile) fmt.Printf("%d%%: %f, ", i, percentile) } println() println() for f := 0.0; f <= 5; f += 0.1 { index := sort.SearchFloat64s(percentiles, f + 0.00000001) fmt.Printf("%f: %d%%, ", f, index) } println() println() }
The text was updated successfully, but these errors were encountered:
There is no built in weighted percentile function in this library. The actual algorithm to use depends on what you're looking for or why you need it.
Do you have an example array and associated weights or can you describe the problem you're trying to solve?
Sorry, something went wrong.
@montanaflynn thanks for answering. See something similar in Python: https://stackoverflow.com/questions/21844024/weighted-percentile-using-numpy
from statsmodels.stats.weightstats import DescrStatsW wq = DescrStatsW(data=np.array([1, 2, 9, 3.2, 4]), weights=np.array([0.0, 0.5, 1.0, 0.3, 0.5])) wq.quantile(probs=np.array([0.1, 0.9]), return_pandas=False) # array([2., 9.])
So I want something like:
percentile, err := stats.PercentileNearestRankWithWeight(values, valueWeights, float64(i))
valueWeights is the weight slice for values. For the original PercentileNearestRank() function, we can view its valueWeights is an all-one slice.
valueWeights
values
PercentileNearestRank()
No branches or pull requests
See: https://en.wikipedia.org/wiki/Percentile#The_weighted_percentile_method
My current code is as follows. But I don't know how to support weighted percentile?
The text was updated successfully, but these errors were encountered: