Google OR-Tools v9.11
a fast and portable software suite for combinatorial optimization
Loading...
Searching...
No Matches
operations_research::sat::Percentile Class Reference

#include <util.h>

Public Member Functions

 Percentile (int record_limit)
 
void AddRecord (double record)
 
int64_t NumRecords () const
 Returns number of stored records.
 
double GetPercentile (double percent)
 

Detailed Description

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.

Definition at line 577 of file util.h.

Constructor & Destructor Documentation

◆ Percentile()

operations_research::sat::Percentile::Percentile ( int record_limit)
inlineexplicit

Definition at line 579 of file util.h.

Member Function Documentation

◆ AddRecord()

void operations_research::sat::Percentile::AddRecord ( double record)

Definition at line 418 of file util.cc.

◆ GetPercentile()

double operations_research::sat::Percentile::GetPercentile ( double percent)
Note
this runs in O(n) for n records.

Interpolate.

Ensure that sorted_records[lower_rank + 1] is in the correct place as if records were actually sorted, the next closest is then the largest element to the left of this element.

Definition at line 425 of file util.cc.

◆ NumRecords()

int64_t operations_research::sat::Percentile::NumRecords ( ) const
inline

Returns number of stored records.

Definition at line 584 of file util.h.


The documentation for this class was generated from the following files: