StatsTests#


Text


MAPIT.core.StatsTests.CUMUF(MUF, GUIObject=None, doTQDM=True, ispar=False)#

This function performs the cumulative MUF test. This is simply the sum of all previous MUF values at a particular time.

\(\text{CUMUF}_t = \sum_{t=0}^t \text{MUF}_t\)

Parameters:
  • MUF (ndarray) – MUF sequence with shape \([n,j]\) where \(n\) is the number of iterations and \(j\) is the temporal dimension. Expects a continuous valued MUF sequence that is similar in format to what is returned by core.StatsTests.MUF.

  • GUIParams (object, default=None) – An optional object that carries GUI related parameters when the API is used inside the MAPIT GUI.

  • doTQDM (bool, default=True) – Controls the use of TQDM progress bar for command line or notebook operation.

Returns:

CUMUF sequence with identical shape to the input MUF.

Return type:

ndarray

MAPIT.core.StatsTests.MUF(inputAppliedError, processedInputTimes, inventoryAppliedError, processedInventoryTimes, outputAppliedError, processedOutputTimes, MBP, GUIObject=None, GUIparams=None, doTQDM=True, ispar=False)#

Function to calculate Material Unaccounted For (MUF), which is sometimes also called ID (inventory difference). Specifically calculates the material balance sequence given some input time series.

\(\text{MUF}_t = I_t - O_t - (C_t - C_{t-1})\)

\(I_t\) is input at time \(t\)

\(O_t\) is output at \(t\)

\(C_t\) is inventory at time \(t\) (note C is used to denote container to have clearer notation rather than using \(I\) with subscripts for both inventory and input)

Important

The lengths and shapes of appliedErrors and processedTimes should be the same. For example:

assert(len(inputAppliedError) == len(processedInputTimes)
assert(inputAppliedError[0].shape == processedInputTimes[0].shape)

See the Input guide for more information.

Parameters:
  • inputAppliedError (list of ndarrays) – A list of ndarrays that has length equal to the total number of input locations. Each array should be \([m,1]\) in shape where \(m\) is the number of samples. This array should reflect observed quantites (as opposed to ground truths). Inputs are assumed to be flows in units of \(\frac{1}{s}\) and will be integrated.

  • processedInputTimes (list of ndarrays) – A list of ndarrays that has length equal to the total number of input locations. Each array should be \([m,1]\) in shape where \(m\) is the number of samples. len(processedInputTimes) and the shape of each list entry (ndarray) should be the same as for inputAppliedError. Each entry in the ndarray should correspond to a timestamp indicating when the value was taken.

  • inventoryAppliedError (list of ndarrays) – A list of ndarrays that has length equal to the total number of inventory locations. Each array should be \([m,1]\) in shape where \(m\) is the number of samples. This array should reflect observed quantites. Inventories are assumed to be in units of mass and will not be integrated.

  • processedInventoryTimes (list of ndarrays) – A list of ndarrays that has length equal to the total number of inventory locations. Each array should be \([m,1]\) in shape where \(m\) is the number of samples. len(processedInventoryTimes) and shape of each list entry (ndarray) should be the same as for inventoryAppliedError. Each entry in the ndarray should corresond to a timestamp indicating when the value was taken.

  • outputAppliedError (list of ndarrays) – A list of ndarrays that has length equal to the total number of output locations. Each array should be \([m,1]\) in shape where \(m\) is the number of samples. This array should reflect observed quantites. Outputs are assumed to be in flows with units of \(\frac{1}{s}\) and will be integrated.

  • processedOutputTimes (list of ndarrays) – A list of ndarrays that has length equal to the total number of output locations. Each array should be \([m,1]\) in shape where \(m\) is the number of samples. len(processedOutputTimes) and shape of each list entry (ndarray) should be the same as for outputAppliedError. Each entry in the ndarray should correspond to a timestamp indicating when the value was taken.

  • MBP (float) – Defines the material balance period.

  • GUIObject (object, default=None) – An optional object that carries GUI related references when the API is used inside the MAPIT GUI.

  • GUIParams (object, default=None) – An optional object that carries GUI related parameters when the API is used inside the MAPIT GUI.

  • doTQDM (bool, default=True) – Controls the use of TQDM progress bar for command line or notebook operation.

Returns:

MUF sequence with shape \([n,j]\) where \(n\) length equal to the maximum time based on the number of material balances that could be constructed given the user provided MBP and number of samples in the input data and \(j\) is the number of iterations given as input. The term \(n\) is calculated by finding the minimum of each of the provided input times.

For example:

import numpy as np

time1[-1] = 400
time2[-1] = 300
time3[-1] = 800

n = np.floor(
      np.min(
        (time1,time2,time3)))

Return type:

ndarray

MAPIT.core.StatsTests.PageTrendTest(inQty, MBP, MBPs, K=0.5, GUIObject=None, doTQDM=True)#

Function for calculating Page’s trend test, which is commonly applied to the SITMUF sequence. Formally compares the null hypothesis that there is no trend versus the alternate trend where there is a trend.

Parameters:
  • inQty (ndarray) – A ndarray with shape \([m,n]\) where \(m\) is the number of iterations and \(n\) is the total number of timesteps.

  • MBP (float) – A float expressing the material balance period.

  • MBPs (float) – The total number of material balance periods present in inQty.

  • K (float, default = 0.5) – Parameter in the trend test.

  • GUIObject (object, default=None) – An optional object that carries GUI related references when the API is used inside the MAPIT GUI.

  • GUIParams (object, default=None) – An optional object that carries GUI related parameters when the API is used inside the MAPIT GUI.

  • doTQDM (bool, default=True) – Controls the use of TQDM progress bar for command line or notebook operation.

Returns:

The results of the trend test which has shape \([m,n]\).

Return type:

ndarray

MAPIT.core.StatsTests.SEMUF(inputAppliedError, processedInputTimes, inventoryAppliedError, processedInventoryTimes, outputAppliedError, processedOutputTimes, MBP, ErrorMatrix, GUIObject=None, doTQDM=True, ispar=False)#

Function for calculating standard error of the material balance sequence (often called SEID or Standard Error of Inventory Difference; \(\sigma _\text{ID}\)). This is accomplished by assuming the error incurred at each location (specified in the ErrorMatrix) rather than estimating it emperically, which is difficult in practice. The equation used here is suitable for most traditional bulk facilities such as enrichment or reprocessing where input and output flows are independent. This function should not be used for facilitiy types where there are more complex statistical dependencies between input, inventory, and output terms (e.g., molten salt reactors). See guide XX for more information.

Parameters:
  • inputAppliedError (list of ndarrays) – A list of ndarrays that has length equal to the total number of input locations. Each array should be \([m,1]\) in shape where \(m\) is the number of samples. This array should reflect observed quantites (as opposed to ground truths). Inputs are assumed to be flows in units of \(\frac{1}{s}\) and will be integrated.

  • processedInputTimes (list of ndarrays) – A list of ndarrays that has length equal to the total number of input locations. Each array should be \([m,1]\) in shape where \(m\) is the number of samples. len(processedInputTimes) and the shape of each list entry (ndarray) should be the same as for inputAppliedError. Each entry in the ndarray should correspond to a timestamp indicating when the value was taken.

  • inventoryAppliedError (list of ndarrays) – A list of ndarrays that has length equal to the total number of inventory locations. Each array should be \([m,1]\) in shape where \(m\) is the number of samples. This array should reflect observed quantites. Inventories are assumed to be in units of mass and will not be integrated.

  • processedInventoryTimes (list of ndarrays) – A list of ndarrays that has length equal to the total number of inventory locations. Each array should be \([m,1]\) in shape where \(m\) is the number of samples. len(processedInventoryTimes) and shape of each list entry (ndarray) should be the same as for inventoryAppliedError. Each entry in the ndarray should corresond to a timestamp indicating when the value was taken.

  • outputAppliedError (list of ndarrays) – A list of ndarrays that has length equal to the total number of output locations. Each array should be \([m,1]\) in shape where \(m\) is the number of samples. This array should reflect observed quantites. Outputs are assumed to be in flows with units of \(\frac{1}{s}\) and will be integrated.

  • processedOutputTimes (list of ndarrays) – A list of ndarrays that has length equal to the total number of output locations. Each array should be \([m,1]\) in shape where \(m\) is the number of samples. len(processedOutputTimes) and shape of each list entry (ndarray) should be the same as for outputAppliedError. Each entry in the ndarray should correspond to a timestamp indicating when the value was taken.

  • MBP (float) – Defines the material balance period.

  • ErrorMatrix (ndarray) – mx1 A ndarray shaped \([M,2]\) where \(M\) is the total number of locations across inputs, inventories, and outputs stacked together (in that order) and 2 refers to the relative random and systematic errors. For example with 2 inputs, 2 inventories, and 2 outputs, ErrorMatrix[3,1] would be the relative systematic error of inventory 2. See guide XX for more information.

  • GUIObject (object, default=None) – An optional object that carries GUI related references when the API is used inside the MAPIT GUI.

  • GUIParams (object, default=None) – An optional object that carries GUI related parameters when the API is used inside the MAPIT GUI.

  • doTQDM (bool, default=True) – Controls the use of TQDM progress bar for command line or notebook operation.

Returns:

tuple containing:

SEID (ndarray): sequence with shape \([n,j,1]\) where \(n\) is the number of material balances and \(j\) is the number of iterations given as input. The term \(n\) is calculated by finding the minimum of each of the provided input times.

SEMUFContribR (ndarray): the random contribution to the overall SEMUF with shape \([j,l,n]\) where \(j\) is the number of iterations given as input, \(l\) is the total number of locations stacked in the order [inputs, inventories, outputs] and \(n\) is the number of material balances.

SEMUFContribS (ndarray): the systematic contribution to the overall SEMUF with shape \([j,l,n]\) where \(j\) is the number of iterations given as input, \(l\) is the total number of locations stacked in the order [inputs, inventories, outputs] and \(n\) is the number of material balances.

ObservedValues (ndarray): the observed values used to calculate SEMUF with shape \([j,l,n]\) where \(j\) is the number of iterations given as input, \(l\) is the total number of locations stacked in the order [inputs, inventories, outputs] and \(n\) is the number of material balances.

Return type:

(tuple)

MAPIT.core.StatsTests.SITMUF(inputAppliedError, processedInputTimes, inventoryAppliedError, processedInventoryTimes, outputAppliedError, processedOutputTimes, ErrorMatrix, MUF, MBP, GUIObject=None, doTQDM=True, ispar=False)#

Function that carries out the standardized independent transformation of MUF. More detailed information can be found in the guide XX.

Parameters:
  • inputAppliedError (list of ndarrays) – A list of ndarrays that has length equal to the total number of input locations. Each array should be \([m,1]\) in shape where \(m\) is the number of samples. This array should reflect observed quantites (as opposed to ground truths). Inputs are assumed to be flows in units of \(\frac{1}{s}\) and will be integrated.

  • processedInputTimes (list of ndarrays) – A list of ndarrays that has length equal to the total number of input locations. Each array should be \([m,1]\) in shape where \(m\) is the number of samples. len(processedInputTimes) and the shape of each list entry (ndarray) should be the same as for inputAppliedError. Each entry in the ndarray should correspond to a timestamp indicating when the value was taken.

  • inventoryAppliedError (list of ndarrays) – A list of ndarrays that has length equal to the total number of inventory locations. Each array should be \([m,1]\) in shape where \(m\) is the number of samples. This array should reflect observed quantites. Inventories are assumed to be in units of mass and will not be integrated.

  • processedInventoryTimes (list of ndarrays) – A list of ndarrays that has length equal to the total number of inventory locations. Each array should be \([m,1]\) in shape where \(m\) is the number of samples. len(processedInventoryTimes) and shape of each list entry (ndarray) should be the same as for inventoryAppliedError. Each entry in the ndarray should corresond to a timestamp indicating when the value was taken.

  • outputAppliedError (list of ndarrays) – A list of ndarrays that has length equal to the total number of output locations. Each array should be \([m,1]\) in shape where \(m\) is the number of samples. This array should reflect observed quantites. Outputs are assumed to be in flows with units of \(\frac{1}{s}\) and will be integrated.

  • processedOutputTimes (list of ndarrays) – A list of ndarrays that has length equal to the total number of output locations. Each array should be \([m,1]\) in shape where \(m\) is the number of samples. len(processedOutputTimes) and shape of each list entry (ndarray) should be the same as for outputAppliedError. Each entry in the ndarray should correspond to a timestamp indicating when the value was taken.

  • MBP (float) – Defines the material balance period.

  • GUIObject (object, default=None) – An optional object that carries GUI related references when the API is used inside the MAPIT GUI.

  • GUIParams (object, default=None) – An optional object that carries GUI related parameters when the API is used inside the MAPIT GUI.

  • doTQDM – Controls the use of TQDM progress bar for command line or notebook operation.