Histogram (Arbitrary Bins) (G Dataflow)

Finds the discrete histogram of a signal based on the given bin specifications.

signal

The input signal.

bins

Boundaries of each bin of the histogram. This input is an array of clusters where each cluster defines the range of values for a bin.

If no bin specifications are provided in bins, this node uses maximum, minimum, number of bins, and inclusion to specify a set of uniformly spaced bins.

lower

Lower boundaries of the bin.

Default: 0

upper

Upper boundaries of the bin.

Default: 0

inclusion

Method to treat the boundaries of each bin.

Name Description
lower Includes the lower boundary.
upper Includes the upper boundary.
both Includes both boundaries.
neither Includes neither boundaries.

Default: lower

maximum

Maximum value to include in the histogram.

Default: 0

minimum

Minimum value to include in the histogram.

Default: 0

error in

Error conditions that occur before this node runs.

The node responds to this input according to standard error behavior.

Standard Error Behavior

Many nodes provide an error in input and an error out output so that the node can respond to and communicate errors that occur while code is running. The value of error in specifies whether an error occurred before the node runs. Most nodes respond to values of error in in a standard, predictable way.

error in does not contain an error error in contains an error
If no error occurred before the node runs, the node begins execution normally.

If no error occurs while the node runs, it returns no error. If an error does occur while the node runs, it returns that error information as error out.

If an error occurred before the node runs, the node does not execute. Instead, it returns the error in value as error out.

Default: No error

number of bins

Number of bins in the histogram.

Default: 10

inclusion

The boundary of each bin to handle.

If bin specifications are provided in bins, this node uses the inclusion in bins instead.

Name Description
lower

Includes the lower boundary.

upper

Includes the upper boundary.

Determining the Bin Widths When inclusion Is lower

If inclusion is set to lower, the bin widths are determined according to the following equations.

${\mathrm{\Delta }}_{0}=\left[\mathrm{min},\text{\hspace{0.17em}}\mathrm{min}+\mathrm{\Delta }x\right)$
${\mathrm{\Delta }}_{1}=\left[\mathrm{min}+\mathrm{\Delta }x,\text{\hspace{0.17em}}\mathrm{min}+2\mathrm{\Delta }x\right)$
$⋮$
${\mathrm{\Delta }}_{i}=\left[\mathrm{min}+i\mathrm{\Delta }x,\text{\hspace{0.17em}}\mathrm{min}+\left(i+1\right)\mathrm{\Delta }x\right)$
$⋮$
${\mathrm{\Delta }}_{k-1}=\left[\mathrm{min}+\left(k-1\right)\mathrm{\Delta }x,\text{\hspace{0.17em}}\mathrm{max}\right]$

where

• $\mathrm{\Delta }x=\frac{\mathrm{max}-\mathrm{min}}{m}$
• max is the maximum
• min is the minimum
• m is the number of bins

Determining the Bin Widths When inclusion Is upper

If inclusion is set to upper, the bin widths are determined according to the following equations.

${\mathrm{\Delta }}_{0}=\left[\mathrm{min},\text{\hspace{0.17em}}\mathrm{min}+\mathrm{\Delta }x\right]$
${\mathrm{\Delta }}_{1}=\left(\mathrm{min}+\mathrm{\Delta }x,\text{\hspace{0.17em}}\mathrm{min}+2\mathrm{\Delta }x\right]$
$⋮$
${\mathrm{\Delta }}_{i}=\left(\mathrm{min}+i\mathrm{\Delta }x,\text{\hspace{0.17em}}\mathrm{min}+\left(i+1\right)\mathrm{\Delta }x\right]$
$⋮$
${\mathrm{\Delta }}_{k-1}=\left(\mathrm{min}+\left(k-1\right)\mathrm{\Delta }x,\text{\hspace{0.17em}}\mathrm{max}\right]$

where

• $\mathrm{\Delta }x=\frac{\mathrm{max}-\mathrm{min}}{m}$
• max is the maximum
• min is the minimum
• m is the number of bins

Default: lower

histogram graph

The histogram of the input signal.

x values

An array of the center values of the bins of the histogram.

histogram h(x)

Discrete histogram of the input signal.

histogram h(x)

Discrete histogram of the input signal.

x values

An array of the center values of the bins of the histogram.

samples outside

Information about points that do not fall in any bin upon successful execution of the node.

total

Total number of values in signal that do not fall in any bin upon successful execution.

below

Number of values in signal below the first bin on the lower boundary.

above

Number of values in signal above the last bin on the upper boundary.

error out

Error information.

The node produces this output according to standard error behavior.

Standard Error Behavior

Many nodes provide an error in input and an error out output so that the node can respond to and communicate errors that occur while code is running. The value of error in specifies whether an error occurred before the node runs. Most nodes respond to values of error in in a standard, predictable way.

error in does not contain an error error in contains an error
If no error occurred before the node runs, the node begins execution normally.

If no error occurs while the node runs, it returns no error. If an error does occur while the node runs, it returns that error information as error out.

If an error occurred before the node runs, the node does not execute. Instead, it returns the error in value as error out.

Algorithm for Obtaining the Histogram

The node completes the following steps to obtain the histogram h(x):

1. Establishes all the bins, which are the intervals, based on the information in bins.
2. Defines the function yi(x).
3. Evaluates histogram h(x).

Algorithm for Calculating the Bin Intervals

The following equation defines the bin intervals.

${\mathrm{\Delta }}_{i}=\left(\mathrm{bins}\left[i\right].\mathrm{lower}:\mathrm{bins}\left[i\right].\mathrm{upper}\right)\text{\hspace{0.17em}}\text{for}\text{\hspace{0.17em}}i=0,\text{\hspace{0.17em}}1,\text{\hspace{0.17em}}2,\text{\hspace{0.17em}}...,\text{\hspace{0.17em}}k-1$

where

• bins[i].lower is the value lower in the ith cluster of array bins
• bins[i].upper is the value upper in the ith cluster of array bins
• k is the number of elements in bins, which consists of the number of total bins

Whether the two ending points bins[i].lower and bins[i].upper of each bin are included in the bin ${\mathrm{\Delta }}_{i}$ depends on the value of inclusion in the corresponding cluster i of bins.

If bins is an empty array, this node uses the inputs maximum, minimum, and number of bins to establish the bins. Each bin width $\mathrm{\Delta }x$ is the same and calculated with the following equation.

The following equation calculates the width of the frequency bin Δx.

$\mathrm{\Delta }x=\frac{\mathrm{max}-\mathrm{min}}{m}$

where

• max is maximum
• min is minimum
• m is number of bins

Algorithm for Defining the Function yi(x)

The following equation defines the function yi(x).

${y}_{i}\left(x\right)=\left\{\begin{array}{c}1\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\mathrm{if}\text{\hspace{0.17em}}x\in {\mathrm{\Delta }}_{i}\\ 0\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\mathrm{elsewhere}\end{array}$

Algorithm for Evaluating the Histogram

This node evaluates the histogram h(x) with the following equation.

${h}_{i}=\underset{j=0}{\overset{n-1}{\sum }}{y}_{i}\left({x}_{j}\right)$

where

• n is the number of elements in the input signal
• hi is the total number of points in the input signal that fall into the bin ${\mathrm{\Delta }}_{i}$
• i = 0, 1, ..., k - 1
• k is number of bins

Where This Node Can Run:

Desktop OS: Windows

FPGA: Not supported

Web Server: Not supported in VIs that run in a web application