1.2.5. Statistics Arrays¶

StatsArrays are objects used in Raysect to store arrays of statistical results with appropriate dimension. Consider for example a 2D pixel array at a camera’s image plane. For each pixel in the camera, Raysect will trace a large number of rays, perhaps many 1000s of individual Ray samples. A StatsArray therefore stores the overall statistical results at each pixel index location. Note that these objects never store the complete set of samples taken by Raysect, as the dataset would be too large for suitable storage. Instead, Raysect stores the mean and variance of all samples collected at each array index location.

Users are unlikely to ever instantiate these classes directly, it is more likely users will encounter these objects in the pipeline results of their observations.

class raysect.core.math.statsarray.StatsBin

Class for storing a single numerical sampling result and its associated statistics.

Variables
• mean (float) – The mean value of the samples.

• variance (float) – The variance of the collected samples.

• samples (int) – The total number of samples in the set.

add_sample()

Add a single sample to this StatsBin.

Parameters

sample (float) – The sample value to be added.

clear()

Erase the current statistics stored in this StatsBin.

combine_samples()

Combine the statistics from another set of samples with the results already stored in this StatsBin.

Parameters
• mean (float) – The mean of the new samples

• variance (float) – The variance of the new samples

• sample_count (int) – The number of new samples that were taken.

copy()

Instantiate a new StatsBin object with the same statistical results.

error()

Compute the standard error of this sample distribution.

class raysect.core.math.statsarray.StatsArray1D

Class for storing a 1D array of sampling results and their associated statistics.

Parameters

length (int) – The length of the 1D samples array.

Variables
• mean (ndarray) – The mean value of the samples.

• variance (ndarray) – The variance of the collected samples.

• samples (ndarray) – The total number of samples in the set.

• length (int) – The length of the 1D samples array.

add_sample()

Add a single sample to the StatsArray1D element x.

Parameters
• x (int) – The position index where the sample should be added.

• sample (float) – The sample value to be added.

clear()

Erase the current statistics stored in this StatsArray.

combine_samples()

Combine the statistics from a given set of samples with the results already stored in this StatsArray at index position x.

Parameters
• x (int) – The index position where these results are to be added.

• mean (float) – The mean of the new samples

• variance (float) – The variance of the new samples

• sample_count (int) – The number of new samples that were taken.

copy()

Instantiate a new StatsArray1D object with the same statistical results.

error()

Compute the standard error of the results at index position x.

Parameters

x (int) – The index position at which to compute the standard error.

errors()

Compute the standard errors of all the results stored in this StatsArray.

Return type

ndarray

shape

The numpy style array shape of the underlying StatsArray.

class raysect.core.math.statsarray.StatsArray2D

Class for storing a 2D array of sampling results and their associated statistics.

Parameters
• nx (int) – The number of array samples along the x direction.

• ny (int) – The number of array samples along the y direction.

Variables
• mean (ndarray) – The mean value of the samples.

• variance (ndarray) – The variance of the collected samples.

• samples (ndarray) – The total number of samples in the set.

• nx (int) – The number of array samples along the x direction.

• ny (int) – The number of array samples along the y direction.

add_sample()

Add a single sample to the StatsArray2D results stored at element x, y.

Parameters
• x (int) – The x position index where the sample should be added.

• y (int) – The y position index where the sample should be added.

• sample (float) – The sample value to be added.

clear()

Erase the current statistics stored in this StatsArray.

combine_samples()

Combine the statistics from a given set of samples with the results already stored in this StatsArray at index position x, y.

Parameters
• x (int) – The x index position where these results are to be added.

• y (int) – The y index position where these results are to be added.

• mean (float) – The mean of the new samples

• variance (float) – The variance of the new samples

• sample_count (int) – The number of new samples that were taken.

copy()

Instantiate a new StatsArray2D object with the same statistical results.

error()

Compute the standard error of the results at index position x, y.

Parameters
• x (int) – The x index position at which to compute the standard error.

• y (int) – The y index position at which to compute the standard error.

errors()

Compute the standard errors of all the results stored in this StatsArray.

Return type

ndarray

shape

The numpy style array shape of the underlying StatsArray.

class raysect.core.math.statsarray.StatsArray3D

Class for storing a 3D array of sampling results and their associated statistics.

Parameters
• nx (int) – The number of array samples along the x direction.

• ny (int) – The number of array samples along the y direction.

• nz (int) – The number of array samples along the z direction.

Variables
• mean (ndarray) – The mean value of the samples.

• variance (ndarray) – The variance of the collected samples.

• samples (ndarray) – The total number of samples in the set.

• nx (int) – The number of array samples along the x direction.

• ny (int) – The number of array samples along the y direction.

• nz (int) – The number of array samples along the z direction.

add_sample()

Add a single sample to the StatsArray3D results stored at element x, y, z.

Parameters
• x (int) – The x position index where the sample should be added.

• y (int) – The y position index where the sample should be added.

• z (int) – The z position index where the sample should be added.

• sample (float) – The sample value to be added.

clear()

Erase the current statistics stored in this StatsArray.

combine_samples()

Combine the statistics from a given set of samples with the results already stored in this StatsArray at index position x, y, z.

Parameters
• x (int) – The x index position where these results are to be added.

• y (int) – The y index position where these results are to be added.

• z (int) – The z index position where these results are to be added.

• mean (float) – The mean of the new samples

• variance (float) – The variance of the new samples

• sample_count (int) – The number of new samples that were taken.

copy()

Instantiate a new StatsArray3D object with the same statistical results.

error()

Compute the standard error of the results at index position x, y, z.

Parameters
• x (int) – The x index position at which to compute the standard error.

• y (int) – The y index position at which to compute the standard error.

• z (int) – The z index position at which to compute the standard error.

errors()

Compute the standard errors of all the results stored in this StatsArray.

Return type

ndarray

shape

The numpy style array shape of the underlying StatsArray.