Skip to content

Commit 1c671b9

Browse files
committed
Added Streams example.
#38
1 parent b6061f4 commit 1c671b9

File tree

1 file changed

+44
-1
lines changed

1 file changed

+44
-1
lines changed

docs/manual.adoc

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,50 @@ StreamSelect indicates the offset in the random number sequence to begin samplin
510510

511511
=== Example
512512

513-
TODO
513+
In this example we will take a NormalStream instance obtain values from it which are then inserted in a Histogram so that we can then print out the contents and associated data. As we have already seen that NormalStream derives from RandomStream along with the other stream types, this example can be easily changed to use something else, such as the ExponentialStream.
514+
515+
----
516+
NormalStream str = new NormalStream(100.0, 2.0);
517+
Histogram hist = new Histogram(10);
518+
519+
for (int i = 0; i < 1000; i++)
520+
{
521+
hist.setValue(str.getNumber());
522+
}
523+
524+
System.out.println("NormalStream error: "+str.error());
525+
526+
hist.print();
527+
----
528+
529+
If you were to execute this code then the output would be similar to the following:
530+
531+
----
532+
NormalStream error: -0.047600000000002085
533+
Maximum number of buckets 10
534+
Merge choice is MEAN
535+
PrecisionHistogram Data:
536+
Number of buckets: 10
537+
Bucket : < 98.63959917087956, 541 >
538+
Bucket : < 99.41934896772582, 1 >
539+
Bucket : < 99.89948948370221, 17 >
540+
Bucket : < 100.00514051631782, 2 >
541+
Bucket : < 100.26527227806514, 1 >
542+
Bucket : < 100.85347549916973, 3 >
543+
Bucket : < 101.31195503916659, 1 >
544+
Bucket : < 101.38562305997606, 1 >
545+
Bucket : < 101.72199923851397, 432 >
546+
Bucket : < 102.68618953365238, 1 >
547+
Variance : 4.00810615160317
548+
Standard Deviation: 2.002025512225848
549+
Number of samples : 1000
550+
Minimum : 93.19494510640277
551+
Maximum : 105.9001968416066
552+
Sum : 100013.85724011554
553+
Mean : 100.01385724011554
554+
----
555+
556+
We will learn more about the Histogram class later in this document.
514557

515558
== Advanced Simulation Classes
516559

0 commit comments

Comments
 (0)