| OLD | NEW |
| (Empty) |
| 1 | |
| 2 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> | |
| 3 <html><head><title>Python: module telemetry.util.statistics</title> | |
| 4 <meta charset="utf-8"> | |
| 5 </head><body bgcolor="#f0f0f8"> | |
| 6 | |
| 7 <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading"> | |
| 8 <tr bgcolor="#7799ee"> | |
| 9 <td valign=bottom> <br> | |
| 10 <font color="#ffffff" face="helvetica, arial"> <br><big><big><strong><a hre
f="telemetry.html"><font color="#ffffff">telemetry</font></a>.<a href="telemetry
.util.html"><font color="#ffffff">util</font></a>.statistics</strong></big></big
></font></td | |
| 11 ><td align=right valign=bottom | |
| 12 ><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href=
"../telemetry/util/statistics.py">telemetry/util/statistics.py</a></font></td></
tr></table> | |
| 13 <p><tt>A collection of statistical utility function
s to be used by metrics.</tt></p> | |
| 14 <p> | |
| 15 <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> | |
| 16 <tr bgcolor="#aa55cc"> | |
| 17 <td colspan=3 valign=bottom> <br> | |
| 18 <font color="#ffffff" face="helvetica, arial"><big><strong>Modules</strong></big
></font></td></tr> | |
| 19 | |
| 20 <tr><td bgcolor="#aa55cc"><tt> </tt></td><td>
</td> | |
| 21 <td width="100%"><table width="100%" summary="list"><tr><td width="25%" valign=t
op><a href="math.html">math</a><br> | |
| 22 </td><td width="25%" valign=top></td><td width="25%" valign=top></td><td width="
25%" valign=top></td></tr></table></td></tr></table><p> | |
| 23 <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> | |
| 24 <tr bgcolor="#eeaa77"> | |
| 25 <td colspan=3 valign=bottom> <br> | |
| 26 <font color="#ffffff" face="helvetica, arial"><big><strong>Functions</strong></b
ig></font></td></tr> | |
| 27 | |
| 28 <tr><td bgcolor="#eeaa77"><tt> </tt></td><td>
</td> | |
| 29 <td width="100%"><dl><dt><a name="-ArithmeticMean"><strong>ArithmeticMean</stron
g></a>(data)</dt><dd><tt>Calculates arithmetic mean.<br> | |
| 30 <br> | |
| 31 Args:<br> | |
| 32 data: A list of samples.<br> | |
| 33 <br> | |
| 34 Returns:<br> | |
| 35 The arithmetic mean value, or 0 if&nbs
p;the list is empty.</tt></dd></dl> | |
| 36 <dl><dt><a name="-Clamp"><strong>Clamp</strong></a>(value, low<font color="#909
090">=0.0</font>, high<font color="#909090">=1.0</font>)</dt><dd><tt>Clamp
a value between some low and high value.</tt>
</dd></dl> | |
| 37 <dl><dt><a name="-Discrepancy"><strong>Discrepancy</strong></a>(samples, locati
on_count<font color="#909090">=None</font>)</dt><dd><tt>Computes the d
iscrepancy of a set of 1D samples from t
he interval [0,1].<br> | |
| 38 <br> | |
| 39 The samples must be sorted. We define the&nbs
p;discrepancy of an empty set<br> | |
| 40 of samples to be zero.<br> | |
| 41 <br> | |
| 42 <a href="http://en.wikipedia.org/wiki/Low-discrepancy_sequence">http://en.wikipe
dia.org/wiki/Low-discrepancy_sequence</a><br> | |
| 43 <a href="http://mathworld.wolfram.com/Discrepancy.html">http://mathworld.wolfram
.com/Discrepancy.html</a></tt></dd></dl> | |
| 44 <dl><dt><a name="-DivideIfPossibleOrZero"><strong>DivideIfPossibleOrZero</stron
g></a>(numerator, denominator)</dt><dd><tt>Returns the quotient,
or zero if the denominator is zero.</tt></dd></dl> | |
| 45 <dl><dt><a name="-DurationsDiscrepancy"><strong>DurationsDiscrepancy</strong></
a>(durations, absolute<font color="#909090">=True</font>, location_count<font co
lor="#909090">=None</font>)</dt><dd><tt>A discrepancy based metri
c for measuring duration jank.<br> | |
| 46 <br> | |
| 47 DurationsDiscrepancy computes a jank metric which
measures how irregular a<br> | |
| 48 given sequence of intervals is. In order to&n
bsp;minimize jank, each duration<br> | |
| 49 should be equally long. This is similar to&nb
sp;how timestamp jank works,<br> | |
| 50 and we therefore reuse the timestamp discrepancy&n
bsp;function above to compute a<br> | |
| 51 similar duration discrepancy number.<br> | |
| 52 <br> | |
| 53 Because timestamp discrepancy is defined in terms&
nbsp;of timestamps, we first<br> | |
| 54 convert the list of durations to monotonically&nbs
p;increasing timestamps.<br> | |
| 55 <br> | |
| 56 Args:<br> | |
| 57 durations: List of interval lengths in 
;milliseconds.<br> | |
| 58 absolute: See TimestampsDiscrepancy.<br> | |
| 59 interval_multiplier: See TimestampsDiscrepancy.</tt></dd><
/dl> | |
| 60 <dl><dt><a name="-GeneralizedMean"><strong>GeneralizedMean</strong></a>(values,
exponent)</dt><dd><tt>See <a href="http://en.wikipedia.org/wiki/Generalize
d_mean">http://en.wikipedia.org/wiki/Generalized_mean</a></tt></dd></dl> | |
| 61 <dl><dt><a name="-GeometricMean"><strong>GeometricMean</strong></a>(values)</dt
><dd><tt>Compute a rounded geometric mean from an&
nbsp;array of values.</tt></dd></dl> | |
| 62 <dl><dt><a name="-Median"><strong>Median</strong></a>(values)</dt><dd><tt>Gets&
nbsp;the median of a list of values.</tt></dd></dl
> | |
| 63 <dl><dt><a name="-NormalizeSamples"><strong>NormalizeSamples</strong></a>(sampl
es)</dt><dd><tt>Sorts the samples, and map them li
nearly to the range [0,1].<br> | |
| 64 <br> | |
| 65 They're mapped such that for the N samples,&n
bsp;the first sample is 0.5/N and the<br> | |
| 66 last sample is (N-0.5)/N.<br> | |
| 67 <br> | |
| 68 Background: The discrepancy of the sample set 
;i/(N-1); i=0, ..., N-1 is 2/N,<br> | |
| 69 twice the discrepancy of the sample set (i+1/
2)/N; i=0, ..., N-1. In our case<br> | |
| 70 we don't want to distinguish between these tw
o cases, as our original domain<br> | |
| 71 is not bounded (it is for Monte Carlo in
tegration, where discrepancy was<br> | |
| 72 first used).</tt></dd></dl> | |
| 73 <dl><dt><a name="-Percentile"><strong>Percentile</strong></a>(values, percentil
e)</dt><dd><tt>Calculates the value below which a
given percentage of values fall.<br> | |
| 74 <br> | |
| 75 For example, if 17% of the values are le
ss than 5.0, then 5.0 is the 17th<br> | |
| 76 percentile for this set of values. When the&n
bsp;percentage doesn't exactly<br> | |
| 77 match a rank in the list of values, the&
nbsp;percentile is computed using linear<br> | |
| 78 interpolation between closest ranks.<br> | |
| 79 <br> | |
| 80 Args:<br> | |
| 81 values: A list of numerical values.<br> | |
| 82 percentile: A number between 0 and 100
.<br> | |
| 83 <br> | |
| 84 Returns:<br> | |
| 85 The Nth percentile for the list of&nbs
p;values, where N is the given percentage.</tt></d
d></dl> | |
| 86 <dl><dt><a name="-StandardDeviation"><strong>StandardDeviation</strong></a>(dat
a)</dt><dd><tt>Calculates the standard deviation.<br> | |
| 87 <br> | |
| 88 Args:<br> | |
| 89 data: A list of samples.<br> | |
| 90 <br> | |
| 91 Returns:<br> | |
| 92 The standard deviation of the samples
provided.</tt></dd></dl> | |
| 93 <dl><dt><a name="-TimestampsDiscrepancy"><strong>TimestampsDiscrepancy</strong>
</a>(timestamps, absolute<font color="#909090">=True</font>, location_count<font
color="#909090">=None</font>)</dt><dd><tt>A discrepancy based me
tric for measuring timestamp jank.<br> | |
| 94 <br> | |
| 95 TimestampsDiscrepancy quantifies the largest area of&nb
sp;jank observed in a series<br> | |
| 96 of timestamps. Note that this is different&n
bsp;from metrics based on the<br> | |
| 97 max_time_interval. For example, the time stamp ser
ies A = [0,1,2,3,5,6] and<br> | |
| 98 B = [0,1,2,3,5,7] have the same max_time_interval&
nbsp;= 2, but<br> | |
| 99 <a href="#-Discrepancy">Discrepancy</a>(B) > <a href="#-Discrepancy
">Discrepancy</a>(A).<br> | |
| 100 <br> | |
| 101 Two variants of discrepancy can be computed:<br> | |
| 102 <br> | |
| 103 Relative discrepancy is following the original def
inition of<br> | |
| 104 discrepancy. It characterized the largest area of&
nbsp;jank, relative to the<br> | |
| 105 duration of the entire time stamp series. &nb
sp;We normalize the raw results,<br> | |
| 106 because the best case discrepancy for a set&n
bsp;of N samples is 1/N (for<br> | |
| 107 equally spaced samples), and we want our metr
ic to report 0.0 in that<br> | |
| 108 case.<br> | |
| 109 <br> | |
| 110 Absolute discrepancy also characterizes the largest&nbs
p;area of jank, but its<br> | |
| 111 value wouldn't change (except for imprecisions due
to a low<br> | |
| 112 |interval_multiplier|) if additional 'good' intervals w
ere added to an<br> | |
| 113 exisiting list of time stamps. Its range&nbs
p;is [0,inf] and the unit is<br> | |
| 114 milliseconds.<br> | |
| 115 <br> | |
| 116 The time stamp series C = [0,2,3,4] and
D = [0,2,3,4,5] have the same<br> | |
| 117 absolute discrepancy, but D has lower relative&nbs
p;discrepancy than C.<br> | |
| 118 <br> | |
| 119 |timestamps| may be a list of lists S =&
nbsp;[S_1, S_2, ..., S_N], where each<br> | |
| 120 S_i is a time stamp series. In that case
, the discrepancy D(S) is:<br> | |
| 121 D(S) = max(D(S_1), D(S_2), ..., D(S_N))</tt></dd></dl> | |
| 122 <dl><dt><a name="-Total"><strong>Total</strong></a>(data)</dt><dd><tt>Returns&n
bsp;the float value of a number or the s
um of a list.</tt></dd></dl> | |
| 123 <dl><dt><a name="-TrapezoidalRule"><strong>TrapezoidalRule</strong></a>(data, d
x)</dt><dd><tt>Calculate the integral according to the&
nbsp;trapezoidal rule<br> | |
| 124 <br> | |
| 125 TrapezoidalRule approximates the definite integral of&n
bsp;f from a to b by<br> | |
| 126 the composite trapezoidal rule, using n subinterva
ls.<br> | |
| 127 <a href="http://en.wikipedia.org/wiki/Trapezoidal_rule#Uniform_grid">http://en.w
ikipedia.org/wiki/Trapezoidal_rule#Uniform_grid</a><br> | |
| 128 <br> | |
| 129 Args:<br> | |
| 130 data: A list of samples<br> | |
| 131 dx: The uniform distance along the x&n
bsp;axis between any two samples<br> | |
| 132 <br> | |
| 133 Returns:<br> | |
| 134 The area under the curve defined by&nb
sp;the samples and the uniform distance<br> | |
| 135 according to the trapezoidal rule.</tt></dd></dl
> | |
| 136 </td></tr></table> | |
| 137 </body></html> | |
| OLD | NEW |