Skip to content
Snippets Groups Projects
ConvertToDistribution-v1.rst 1.37 KiB
Newer Older
.. algorithm::

.. summary::

.. alias::

.. properties::

Description
-----------

Makes a histogram workspace a distribution i.e. divides by the bin width.

Restrictions on the input workspace
###################################
The workspace to convert must contain histogram data which is not already flagged as a distribution.

Usage
-----

**Example - converting multiple peaks to distribution**

.. testcode:: ConvertToDistribution

    ws_multi = CreateSampleWorkspace("Histogram", "Multiple Peaks")

    print "Is the workspace a distribution? " + str(ws_multi.isDistribution())

    print "The workspace has a level backgound of " + str(ws_multi.readY(0)[0]) + " counts."
    print "The largest of which is " + str(ws_multi.readY(0)[60]) + " counts."

    ConvertToDistribution(ws_multi)

    print "Is the workspace a distribution? " + str(ws_multi.isDistribution())
    print "The workspace has a level backgound of " + str(ws_multi.readY(0)[0]) + " counts."
    print "The largest of which is " + str(ws_multi.readY(0)[60]) + " counts."

Output:

.. testoutput:: ConvertToDistribution

    Is the workspace a distribution? False
    The workspace has a level backgound of 0.3 counts.
    The largest of which is 8.3 counts.

    Is the workspace a distribution? True
    The workspace has a level backgound of 0.0015 counts.
    The largest of which is 0.0415 counts.