Stay organized with collections
Save and categorize content based on your preferences.
C++ Reference: class Percentile
Note: This documentation is automatically generated.
Utility to calculate percentile (First variant) for limited number of
records. Reference:
https://en.wikipedia.org/wiki/Percentile
After the vector is sorted, we assume that the element with index i
correspond to the percentile 100*(i+0.5)/size. For percentiles before the
first element (resp. after the last one) we return the first element (resp.
the last). And otherwise we do a linear interpolation between the two element
around the asked percentile.
Method |
AddRecord | Return type: void Arguments: double record |
GetPercentile | Return type: double Arguments: double percent Note that this is not fast and runs in O(n log n) for n records.
|
NumRecords | Return type: int64_t Returns number of stored records.
|
Percentile | Return type: explicit Arguments: int record_limit |
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-08-06 UTC.
[null,null,["Last updated 2024-08-06 UTC."],[[["\u003cp\u003eThe \u003ccode\u003ePercentile\u003c/code\u003e class is a utility for calculating percentiles for a limited number of records, referencing the Wikipedia definition of percentile.\u003c/p\u003e\n"],["\u003cp\u003eIt assumes the sorted element with index \u003ccode\u003ei\u003c/code\u003e corresponds to the percentile \u003ccode\u003e100*(i+0.5)/size\u003c/code\u003e, performing linear interpolation for percentiles between elements.\u003c/p\u003e\n"],["\u003cp\u003eIt provides methods to add records (\u003ccode\u003eAddRecord\u003c/code\u003e), retrieve a specific percentile (\u003ccode\u003eGetPercentile\u003c/code\u003e), and get the total number of records (\u003ccode\u003eNumRecords\u003c/code\u003e).\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eGetPercentile\u003c/code\u003e has a time complexity of O(n log n) for n records.\u003c/p\u003e\n"]]],["The `Percentile` class calculates percentiles for a limited number of records. It uses a sorted vector, with element index `i` corresponding to the percentile `100*(i+0.5)/size`. `AddRecord` adds a record. `GetPercentile` retrieves the percentile, using linear interpolation between elements for requested values, and it runs in O(n log n). `NumRecords` returns the count of stored records. The constructor initializes the record limit.\n"],null,["# Percentile\n\nC++ Reference: class Percentile\n===============================\n\n\nNote: This documentation is automatically generated.\nUtility to calculate percentile (First variant) for limited number of records. Reference: \u003chttps://en.wikipedia.org/wiki/Percentile\u003e \n\nAfter the vector is sorted, we assume that the element with index i correspond to the percentile 100\\*(i+0.5)/size. For percentiles before the first element (resp. after the last one) we return the first element (resp. the last). And otherwise we do a linear interpolation between the two element around the asked percentile.\n\n| Method ||\n|-----------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------|\n| [`AddRecord`](https://github.com/google/or-tools/blob/v9.4/ortools/sat/util.h#L323) | Return type: `void ` Arguments: `double record` \u003cbr /\u003e |\n| [`GetPercentile`](https://github.com/google/or-tools/blob/v9.4/ortools/sat/util.h#L329) | Return type: `double ` Arguments: `double percent` Note that this is not fast and runs in O(n log n) for n records. |\n| [`NumRecords`](https://github.com/google/or-tools/blob/v9.4/ortools/sat/util.h#L326) | Return type: `int64_t ` Returns number of stored records. |\n| [`Percentile`](https://github.com/google/or-tools/blob/v9.4/ortools/sat/util.h#L321) | Return type: `explicit ` Arguments: `int record_limit` \u003cbr /\u003e |"]]