\(\renewcommand\AA{\unicode{x212B}}\)

CalculateZscore v1

Summary

Calculate Z-score for Y and E of MatrixWorkspace.

Properties

Name

Direction

Type

Default

Description

InputWorkspace

Input

MatrixWorkspace

Mandatory

Name of input MatrixWorkspace to have Z-score calculated.

OutputWorkspace

Output

Workspace2D

Mandatory

Name of the output Workspace2D containing the Z-scores.

WorkspaceIndex

Input

number

Optional

Index of the spetrum to have Z-score calculated. Default is to calculate for all spectra.

Description

Calculate Z-score of a spectrum in a given workspace.

Definition of Z-score

The standard score of a raw score \(x\) is:

\[z = \frac{x-\mu}{\sigma}.\]

where (1) \(\mu\) is the mean of the population and (2) \(\sigma\) is the standard deviation of the population.

Usage

Example - calculate Z-score for a single spectrum workspace:

# create histogram workspace
dataX = [0,1,2,3,4,5,6,7,8,9]
dataY = [1,1.5,-11,1,19,1,1,2,1]
ws = CreateWorkspace(dataX, dataY)

# rebin from min to max with size bin = 2
ws2 = CalculateZscore(InputWorkspace=ws)

print("The Z-scores are: {}".format(ws2.readY(0)))

Output:

The Z-scores are: [ 0.11618485  0.04647394  1.78924674  0.11618485  2.39340797  0.11618485
  0.11618485  0.02323697  0.11618485]

Categories: AlgorithmIndex | Utility\Calculation

Source

C++ header: CalculateZscore.h

C++ source: CalculateZscore.cpp