THist


The THist function creates a simple histogram of a table of numbers. This function uses the CHistogram class with automatic bin width. The number of bins used for the histogram can be determined from the number of elements in the table.

Syntax

tableHist = THist( table )

where

    table is a Lua table containing the target data.

    tableHist is a new table that contains the histogram frequencies.

  

This function expedites histogram calculation using default "nice" histogram parameters. The function uses the default settings of the CHistogram class and returns the histogram as a new table. The number of bins, or table elements, can be determined from the number of table element returneds; for returned histogram tHist, the number of bins is given by table.getn( tHist ).

Example

The following script computes and plots a histogram of 1 million Gaussian random numbers.

h = THist( TGaussDev(1000000) )

-- compute it

PlotConnect( TSeries(table.getn(h)), h )

-- plot h against 1, 2, 3, ...

Note that the number of points to plot is obtained from the returned histogram table using the built-in table.getn() function on the returned histogram array, h. The TSeries function creates a table of abscissa values in integer steps from 1 to table.getn(h).

Related Topics

CHistogram Class

TSeries

TGaussDev

ConnectedPlot