Skip to content

Commit

Permalink
Refs #9573. Checkpointing work for docs of 2 algorithms.
Browse files Browse the repository at this point in the history
1. CalculateZscore;
2. EstimatePDDetectorResolution
  • Loading branch information
wdzhou committed Jun 9, 2014
1 parent cb358f0 commit 96ba8e7
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 0 deletions.
38 changes: 38 additions & 0 deletions Code/Mantid/docs/source/algorithms/CalculateZscore-v1.rst
Expand Up @@ -11,4 +11,42 @@ Description

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

Definition of Z-score
#####################

The standard score of a raw score :math:`x` is:

.. math:: z = \frac{x-\mu}{\sigma}.

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


Usage
-----

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

.. testcode:: ExHistSimple

# 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: " + str(ws2.readY(0))

.. testcleanup:: ExHistSimple

DeleteWorkspace(ws)
DeleteWorkspace(ws2)

Output:

.. testoutput:: ExHistSimple

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

.. categories::
Expand Up @@ -54,4 +54,36 @@ Detector size: 0.005 x 0.0543

Range of :math:`\Delta\theta\cot\theta`: :math:`(0.00170783, 0.0167497)`


Usage
-----

**Example - simple rebin of a histogram workspace:**

.. testcode:: ExHistSimple

# Load a Nexus file
Load(Filename="PG3_2538_2k.nxs", OutputWorkspace="PG3_2538")
# Run the algorithm to estimate detector's resolution
EstimatePDDetectorResolution(InputWorkspace="PG3_2538", DeltaTOF=40.0, OutputWorkspace="PG3_Resolution")
resws = mtd["PG3_Resolution"]

print "Size of workspace 'PG3_Resolution' = ", resws.getNumberHistograms()
print "Estimated resolution of detector of spectrum 0 = ", resws.readY(0)[0]
print "Estimated resolution of detector of spectrum 100 = ", resws.readY(100)[0]
print "Estimated resolution of detector of spectrum 999 = ", resws.readY(999)[0]

.. testcleanup:: ExHistSimple

DeleteWorkspace(resws)

Output:

.. testoutput:: ExHistSimple

Size of workspace 'PG3_Resolution' = 1000
Estimated resolution of detector of spectrum 0 = 0.00323913250277
Estimated resolution of detector of spectrum 100 = 0.00323608373204
Estimated resolution of detector of spectrum 999 = 0.00354849279137

.. categories::
Binary file added Test/AutoTestData/UsageData/PG3_2538_2k.nxs
Binary file not shown.

0 comments on commit 96ba8e7

Please sign in to comment.