Skip to content

Commit 40c0f2f

Browse files
committed
Added Stats example
#37
1 parent 5cd8a81 commit 40c0f2f

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed

docs/manual.adoc

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -915,6 +915,61 @@ The actual quantile value is provided by the getValue() method.
915915

916916
=== Example
917917

918+
In this example, similar to the one we saw earlier when discussing streams, takes a NormalStream and pushes the data obtained from it into a Quantile instance (also a PrecisionHistogram, as seen above).
919+
920+
----
921+
NormalStream str = new NormalStream(100.0, 2.0);
922+
Quantile hist = new Quantile();
923+
924+
for (int i = 0; i < 20; i++)
925+
{
926+
hist.setValue(str.getNumber());
927+
}
928+
929+
System.out.println("NormalStream error: "+str.error());
930+
931+
hist.print();
932+
----
933+
934+
If you execute this code then you will see something like the following:
935+
936+
----
937+
NormalStream error: -0.12180000000000302
938+
Quantile precentage : 0.95
939+
Value below which percentage occurs 103.2525536140605
940+
PrecisionHistogram Data:
941+
Number of buckets: 20
942+
Bucket : < 95.4184404867909, 1 >
943+
Bucket : < 96.77470267057221, 1 >
944+
Bucket : < 98.06420534765873, 1 >
945+
Bucket : < 98.51326185839879, 1 >
946+
Bucket : < 98.83083271038129, 1 >
947+
Bucket : < 99.02208650724813, 1 >
948+
Bucket : < 99.25398638929686, 1 >
949+
Bucket : < 99.61818993348244, 1 >
950+
Bucket : < 99.69668527826141, 1 >
951+
Bucket : < 99.90066145276452, 1 >
952+
Bucket : < 100.13242192897384, 1 >
953+
Bucket : < 100.16716965330903, 1 >
954+
Bucket : < 100.29000453526925, 1 >
955+
Bucket : < 100.6675785365828, 1 >
956+
Bucket : < 100.79956320347745, 1 >
957+
Bucket : < 100.8830352383034, 1 >
958+
Bucket : < 101.04146043991506, 1 >
959+
Bucket : < 101.30326745585228, 1 >
960+
Bucket : < 103.2525536140605, 1 >
961+
Bucket : < 103.56896793616222, 1 >
962+
Variance : 3.588431232925933
963+
Standard Deviation: 1.8943155051168041
964+
Number of samples : 20
965+
Minimum : 95.4184404867909
966+
Maximum : 103.56896793616222
967+
Sum : 1997.199075176761
968+
Mean : 99.85995375883805
969+
----
970+
971+
Because Quantile is also a PrecisionHistogram, every unique number is assigned a unique bucket instance.
972+
918973
== References
919974

920975
[1] link:http://dl.acm.org/citation.cfm?id=1096934[G. M. Birtwistle, O-J. Dahl, B. Myhrhaug, K. Nygaard, “Simula Begin”, Academic Press, 1973].

0 commit comments

Comments
 (0)