|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.threerings.parlor.rating.util.Percentiler
public class Percentiler
Used to keep track of the percentile distribution of positive values (generally puzzle scores).
| Field Summary | |
|---|---|
protected int[] |
_counts
A histogram of all values recorded to this percentiler. |
protected boolean |
_fixedRange
If this Percentiler was created with a fixed range. |
protected int |
_max
The maximum value seen by this percentiler. |
protected int |
_min
The minimum value seen by this percentiler. |
protected int |
_nextRecomp
Counts down to our next recalculation. |
protected byte[] |
_percentile
The percentile associated with each bucket. |
protected byte[] |
_reverse
The bucket associated with each percentile. |
protected long |
_snapTotal
The value of _total at creation time or as of a call to clearModified(). |
protected long |
_total
The total number of data points seen by this percentiler. |
protected static int |
BUCKET_COUNT
The number of divisions between zero and our maximum value, which defines the granularity of our histogram. |
protected static int |
INT_SIZE
Number of bytes in an int; makes code clearer. |
| Constructor Summary | |
|---|---|
Percentiler()
Creates an empty percentiler. |
|
Percentiler(byte[] data)
Creates a percentiler from its serialized representation. |
|
Percentiler(int min,
int max)
Creates a percentiler that expects values to fall within the given range. |
|
| Method Summary | |
|---|---|
void |
clearModified()
Clears this percentiler's "is modified" state. |
void |
dump(PrintWriter out)
Dumps a text representation of this percentiler to the supplied print stream. |
void |
dumpGnuPlot(PrintWriter out)
Dumps out our data in a format that can be used to generate a gnuplot. |
int[] |
getCounts()
Returns the counts for each bucket. |
int |
getMaxScore()
Returns the largest score seen by this percentiler. |
int |
getMinScore()
Returns the smallest score seen by this percentiler. |
int |
getPercentile(float value)
Returns the percent of all numbers seen that are lower than the specified value. |
long |
getRecordedCount()
Returns the total number of values ever recorded to this percentiler. |
float |
getRequiredScore(int percentile)
Returns the score necessary to attain the specified percentile. |
float[] |
getRequiredScores()
Returns the scores required to obtain a percentile rating from 0 to 99. |
boolean |
isModified()
Returns true if thsi percentiler has been modified since it was created or since the last call to clearModified(). |
void |
recomputePercentiles()
Recomputes the percentile cutoffs based on the values recorded since the last percentile computation. |
void |
recordValue(float value)
Records a value, updating the histogram but not the percentiles (a call to recomputePercentiles() is required for that and is sufficiently expensive that it shouldn't
be done every time a value is added). |
void |
recordValue(float value,
boolean logNewMax)
See recordValue(float). |
protected String |
spaces(int count)
|
protected int |
toBucketIndex(float value)
Returns the histogram bucket to which this value is assigned. |
byte[] |
toBytes()
Converts this percentiler to a byte array so that it may be stored into a database. |
String |
toString()
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected boolean _fixedRange
protected long _total
protected long _snapTotal
_total at creation time or as of a call to clearModified().
protected int _min
protected int _max
protected int _nextRecomp
protected int[] _counts
protected byte[] _percentile
protected byte[] _reverse
protected static final int BUCKET_COUNT
protected static final int INT_SIZE
| Constructor Detail |
|---|
public Percentiler()
public Percentiler(int min,
int max)
public Percentiler(byte[] data)
| Method Detail |
|---|
public void recordValue(float value)
recomputePercentiles() is required for that and is sufficiently expensive that it shouldn't
be done every time a value is added).
public void recordValue(float value,
boolean logNewMax)
recordValue(float).
public long getRecordedCount()
public boolean isModified()
clearModified().
public void clearModified()
public int getPercentile(float value)
recomputePercentiles().
public float getRequiredScore(int percentile)
recomputePercentiles().
percentile - the desired percentile (from 0 to 99 inclusive).public int getMaxScore()
public int getMinScore()
public float[] getRequiredScores()
public int[] getCounts()
public void recomputePercentiles()
public byte[] toBytes()
public String toString()
toString in class Objectpublic void dumpGnuPlot(PrintWriter out)
public void dump(PrintWriter out)
protected final String spaces(int count)
protected final int toBucketIndex(float value)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||