**12.2****
****Adding Data to Histograms** (.NET, C#, CSharp, VB, Visual Basic, F#)

The provided AddData()
method adds a vector of data to a **Histogram**.
The histogram bin count containing each given data point is updated.
For example, this code constructs a vector of 100
random numbers from a normal distribution and adds the data to **Histogram** hist.

Code Example – C# histogram

double mean = 70.0;

double variance = 10.0;

var rng = new RandGenNormal( mean, variance );

var v = new DoubleVector( 100, rng );

hist.AddData( v );

Code Example – VB histogram

Dim Mean As Double = 70.0

Dim Variance As Double = 10.0

Dim RNG As New RandGenNormal(Mean, Variance)

Dim V As New DoubleVector(100, RNG)

Hist.AddData(V)

As a convenience, the **Histogram**
class also provides a constructor that accepts the number of bins and
a vector data. The constructed bins are of equal size and scaled with
the maximum and minimum data. The counts in the histogram are initialized
with the contents of the given vector. Thus:

Code Example – C# histogram

var hist = new Histogram( 20, v );

Code Example – VB histogram

Dim Hist As New Histogram(20, V)

Lastly, you can add a single data point to a histogram using an overload of the AddData() method that accepts a double:

Code Example – C# histogram

double d = 5.34;

hist.AddData( d );

Code Example – VB histogram

Dim D As Double = 5.34

Hist.AddData(D)