Histogram (Arbitrary Bins) (G Dataflow)

Version:

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.

lower

Lower boundaries of the bin.

upper

Upper boundaries of the bin.

inclusion

Method to treat the boundaries of each 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.

Name Value Description
lower 0

Includes the lower boundary.

upper 1

Includes the upper boundary.

both 2

Includes both boundaries.

neither 3

Includes neither boundaries.

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.

Default: No error

number of bins

Number of bins in the histogram.

Default: 10

inclusion

The boundary of each bin to handle.

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 not falling in any bin upon successful execution of the node.

total

Total number of values in signal not falling 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.

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 the input array bins.
2. Defines the function yi(x).
3. Evaluates the 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 the maximum
• min is the minimum
• m is the 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 the number of bins

Where This Node Can Run:

Desktop OS: Windows

FPGA: Not supported