WeightedMeanOfWorkspace v1

../_images/WeightedMeanOfWorkspace-v1_dlg.png

WeightedMeanOfWorkspace dialog.

Summary

This algorithm calculates the weighted mean for an entire workspace.

Properties

Name Direction Type Default Description
InputWorkspace Input MatrixWorkspace Mandatory An input workspace.
OutputWorkspace Output MatrixWorkspace Mandatory An output workspace.

Description

This algorithm calculates the weighted mean from all the spectra in a given workspace. Monitors and masked spectra are ignored. Also, individual bins with IEEE values will be excluded from the result. The weighted mean calculated by the following:

\displaystyle y=\frac{\sum\frac{x_i}{\sigma^{2}_i}}{\sum\frac{1}{\sigma^{2}_i}}

and the variance is calculated by:

\displaystyle \sigma^{2}_y=\frac{1}{\sum\frac{1}{\sigma^{2}_i}}

Usage

dataX = range(1,13)
dataY = range(1,12)
dataE = range(1,12)
ws = CreateWorkspace(dataX, dataY, dataE)
ws1 = WeightedMeanOfWorkspace(ws)
print("Weighted Mean of Workspace: {}".format(str(ws1.readY(0))))
print("Weighted Mean Error of Workspace: {}".format(str(ws1.readE(0))))

Output:

Weighted Mean of Workspace: [ 1.93826376]
Weighted Mean Error of Workspace: [ 1.2482116]

Categories: AlgorithmIndex | Arithmetic

Source

C++ source: WeightedMeanOfWorkspace.cpp (last modified: 2019-06-05)

C++ header: WeightedMeanOfWorkspace.h (last modified: 2018-10-05)