Skip to content

Commit a8b1d2b

Browse files
committed
Added initial Mean text
Needs maths fixing up.
1 parent 43413ce commit a8b1d2b

1 file changed

Lines changed: 51 additions & 0 deletions

File tree

docs/manual.adoc

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -635,3 +635,54 @@ If the semaphore is garbage collected with processes waiting for it then an erro
635635
== Statistical classes
636636

637637
The purpose of a simulation typically involves the gathering of relevant statistical information, e.g., the average length of time spent in a queue. JavaSim provides a number of different classes for gathering such information. These classes can be found in the org.javasim.stats package.
638+
639+
=== Mean
640+
641+
This is the basic class from which others are derived, gathering statistical information on the samples provided to it.
642+
643+
----
644+
public class Mean
645+
{
646+
public void setValue (double value) throws IllegalArgumentException;
647+
648+
public void reset ();
649+
650+
public int numberOfSamples (); public double min ();
651+
652+
public double max (); public double sum (); public double mean ();
653+
654+
public boolean saveState (String fileName) throws IOException;
655+
656+
public boolean saveState (DataOutputStream oFile) throws IOException;
657+
658+
public boolean restoreState (String fileName) throws FileNotFoundException, IOException;
659+
660+
public boolean restoreState (DataInputStream iFile) throws IOException;
661+
662+
public void print ();
663+
};
664+
----
665+
666+
New values can be supplied to the instance of the Mean class using the setValue(double) method. The number of samples which have been give can be obtained from numberOfSamples().
667+
668+
The maximum and minimum of the samples supplied can be obtained from the max() and min() methods, respectively.
669+
670+
sum() returns the summation of all of the samples:
671+
672+
n
673+
Σ Si
674+
675+
i=1
676+
677+
mean() returns the mean value:
678+
679+
n
680+
1_n Σ Si
681+
682+
i=1
683+
684+
An instance of Mean can be reset between samples using the reset() method.
685+
686+
If the state of a Mean object is required to be saved between simulation runs then it can be made persistent by using either of the saveState methods. The first instance saves the state to a file, whereas the second can be used to save the state to an instance of the java.io.DataOutputStream class. There are likewise two corresponding ways in which the state can be restored.
687+
688+
The print method simply prints to System.out the current state of the object.

0 commit comments

Comments
 (0)