Package jsl.utilities.statistic.welch
Class WelchDataArrayObserver
- java.lang.Object
-
- jsl.observers.ModelElementObserver
-
- jsl.utilities.statistic.welch.WelchDataArrayObserver
-
- All Implemented Interfaces:
ObserverIfc
,GetNameIfc
,IdentityIfc
public class WelchDataArrayObserver extends ModelElementObserver
Collects Welch data in to an array. The size of the array must be specified when creating the observer. Any data that is observed that results in more data than the array size is ignored (not stored). Permits the creation of CSV files that hold the data and the Welch plotting data This is essentially an in memory version of the WelchDataFileObserver
-
-
Field Summary
-
Fields inherited from class jsl.observers.ModelElementObserver
myName
-
-
Constructor Summary
Constructors Constructor Description WelchDataArrayObserver(ResponseVariable responseVariable, double batchSize)
Defaults to a maximum number of observations of 50000 and maximum number of replications of 20WelchDataArrayObserver(ResponseVariable responseVariable, int maxNumObs, int maxNumReps, double batchSize)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
afterExperiment(ModelElement m, java.lang.Object arg)
protected void
afterReplication(ModelElement m, java.lang.Object arg)
protected void
beforeExperiment(ModelElement m, java.lang.Object arg)
protected void
beforeReplication(ModelElement m, java.lang.Object arg)
static WelchDataArrayObserver
createWelchFileObserver(ResponseVariable responseVariable)
Creates a WelchDataArrayObserver with batch size 1 Defaults to a maximum number of observations of 10000 and maximum number of replications of 20static WelchDataArrayObserver
createWelchFileObserver(ResponseVariable responseVariable, int maxNumObs, int maxNumReps)
Creates a WelchDataArrayObserver with batch size 1static WelchDataArrayObserver
createWelchFileObserver(TimeWeighted timeWeighted)
Creates a WelchDataArrayObserver with batch size 10.static WelchDataArrayObserver
createWelchFileObserver(TimeWeighted timeWeighted, int maxNumObs, int maxNumReps, double deltaTInterval)
Creates a WelchDataArrayObserver with batch size 10.double[]
getAvgTimeBtwObservationsForEachReplication()
double
getBatchSize()
double[][]
getData()
Columns are the replications, rows are the datadouble
getLastTime()
double
getLastValue()
long
getMinNumberOfObservationsAcrossReplications()
long[]
getNumberOfObservationsForEachReplication()
int
getNumberOfReplications()
double[]
getReplicationAverages()
double[]
getReplicationData(int repNum)
java.lang.String
getResponseName()
double[]
getTimeOfLastObservationForReps()
double[]
getWelchAverages()
Welch average is across each replication for each observationdouble[]
getWelchCumulativeAverages()
Gets an array that contains the cumulative average over the Welch Averagesvoid
makeCSVWelchData()
This results in a comma separated value file that has each row containing each observation for each replication and each replication as columns.void
makeCSVWelchPlotData()
Makes and writes out the welch plot data.java.lang.String
toString()
protected void
update(ModelElement m, java.lang.Object arg)
-
Methods inherited from class jsl.observers.ModelElementObserver
getId, getModelElement, getName, initialize, montecarlo, removedFromModel, replicationEnded, setModelElement, setName, timedUpdate, update, warmUp
-
-
-
-
Constructor Detail
-
WelchDataArrayObserver
public WelchDataArrayObserver(ResponseVariable responseVariable, double batchSize)
Defaults to a maximum number of observations of 50000 and maximum number of replications of 20- Parameters:
responseVariable
- the ResponseVariable or TimeWeighted variable to observebatchSize
- the batch size for condensing the data
-
WelchDataArrayObserver
public WelchDataArrayObserver(ResponseVariable responseVariable, int maxNumObs, int maxNumReps, double batchSize)
- Parameters:
responseVariable
- the ResponseVariable or TimeWeighted variable to observemaxNumObs
- the limit on the number of observations in each replication to storemaxNumReps
- the limit on the number of replicationsbatchSize
- the batch size for condensing the data
-
-
Method Detail
-
createWelchFileObserver
public static WelchDataArrayObserver createWelchFileObserver(ResponseVariable responseVariable)
Creates a WelchDataArrayObserver with batch size 1 Defaults to a maximum number of observations of 10000 and maximum number of replications of 20- Parameters:
responseVariable
- the ResponseVariable to observe- Returns:
- the created WelchDataArrayObserver
-
createWelchFileObserver
public static WelchDataArrayObserver createWelchFileObserver(ResponseVariable responseVariable, int maxNumObs, int maxNumReps)
Creates a WelchDataArrayObserver with batch size 1- Parameters:
responseVariable
- the ResponseVariable or TimeWeighted variable to observemaxNumObs
- the limit on the number of observations in each replication to storemaxNumReps
- the limit on the number of replications
-
createWelchFileObserver
public static WelchDataArrayObserver createWelchFileObserver(TimeWeighted timeWeighted)
Creates a WelchDataArrayObserver with batch size 10. The discretizing interval of 10 time units Defaults to a maximum number of observations of 10000 and maximum number of replications of 20- Parameters:
timeWeighted
- the TimeWeighted to observe- Returns:
- the created WelchDataArrayObserver
-
createWelchFileObserver
public static WelchDataArrayObserver createWelchFileObserver(TimeWeighted timeWeighted, int maxNumObs, int maxNumReps, double deltaTInterval)
Creates a WelchDataArrayObserver with batch size 10. The discretizing interval of 10 time units Defaults to a maximum number of observations of 10000 and maximum number of replications of 20- Parameters:
timeWeighted
- the TimeWeighted to observemaxNumObs
- the limit on the number of observations in each replication to storemaxNumReps
- the limit on the number of replications- Returns:
- the created WelchDataArrayObserver
-
makeCSVWelchData
public final void makeCSVWelchData()
This results in a comma separated value file that has each row containing each observation for each replication and each replication as columns. The last two columns are avg is the average across the replications and cumAvg. The file is flushed and closed. The file is stored in the base directory holding the welch data files and has the name of the data with _WelchData.csv appended. The header row is: Rep1, Rep2, ..., RepN, Avg, CumAvg
-
makeCSVWelchPlotData
public final void makeCSVWelchPlotData()
Makes and writes out the welch plot data. Squelches inconvenient IOExceptions The file is stored in the base directory holding the welch data files and has the name of the data with _WelchPlotData.csv appended. The header row is Avg, CumAvg
-
getResponseName
public java.lang.String getResponseName()
-
toString
public java.lang.String toString()
- Overrides:
toString
in classModelElementObserver
-
getBatchSize
public double getBatchSize()
-
getLastTime
public double getLastTime()
-
getLastValue
public double getLastValue()
-
getNumberOfObservationsForEachReplication
public long[] getNumberOfObservationsForEachReplication()
-
getAvgTimeBtwObservationsForEachReplication
public double[] getAvgTimeBtwObservationsForEachReplication()
-
getReplicationAverages
public double[] getReplicationAverages()
-
getTimeOfLastObservationForReps
public double[] getTimeOfLastObservationForReps()
-
getNumberOfReplications
public int getNumberOfReplications()
-
getMinNumberOfObservationsAcrossReplications
public long getMinNumberOfObservationsAcrossReplications()
- Returns:
- the minimum number of observations across the replications
-
getWelchAverages
public double[] getWelchAverages()
Welch average is across each replication for each observation- Returns:
- an array of the Welch averages
-
getWelchCumulativeAverages
public double[] getWelchCumulativeAverages()
Gets an array that contains the cumulative average over the Welch Averages- Returns:
- returns an array that contains the cumulative average
-
getData
public double[][] getData()
Columns are the replications, rows are the data- Returns:
- a copy of the data
-
getReplicationData
public double[] getReplicationData(int repNum)
- Parameters:
repNum
- the replication number 1, 2, etc- Returns:
- the within replication data for the indicated replication
-
beforeExperiment
protected void beforeExperiment(ModelElement m, java.lang.Object arg)
- Overrides:
beforeExperiment
in classModelElementObserver
-
beforeReplication
protected void beforeReplication(ModelElement m, java.lang.Object arg)
- Overrides:
beforeReplication
in classModelElementObserver
-
afterReplication
protected void afterReplication(ModelElement m, java.lang.Object arg)
- Overrides:
afterReplication
in classModelElementObserver
-
update
protected void update(ModelElement m, java.lang.Object arg)
- Overrides:
update
in classModelElementObserver
-
afterExperiment
protected void afterExperiment(ModelElement m, java.lang.Object arg)
- Overrides:
afterExperiment
in classModelElementObserver
-
-