# Adding frequency count cells to a histogram

One common reason for editing histograms is to add frequency
count cells without greatly increasing the number of steps. The
changes you will need to make to histograms vary, depending on whether
the values represent a dense or sparse frequency count.

## Editing a histogram with a dense frequency count

To add a frequency cell for a given column value, check the
column value just less than the value for the new cell. If the next-lesser
value is as close as possible to the value to be added, then the
frequency count determined simply.

If the next lesser column value to the step to be changed
is as close as possible to the frequency count value, then the frequency
count cell can be extracted simply.

For example, if a column contains at least one 19 and many
20s, and the histogram uses a single cell to represent all the values
greater than 17 and less than or equal to 22, **optdiag** output
shows the following information for the cell:

Step Weight Value
...
4 0.100000000 <= 17
5 0.400000000 <= 22
...

Altering this histogram to place the value 20 on its own step
requires adding two steps, as shown here:

...
4 0.100000000 <= 17
5 0.050000000 <= 19
6 0.300000000 <= 20
7 0.050000000 <= 22
...

In the altered histogram above, step 5 represents all values
greater than 17 and less than or equal to 19. The sum of the weights
of steps 5, 6, and 7 in the modified histogram equals the original
weight value for step 5.

## Editing a histogram with a sparse frequency count

If the column has no values greater than 17 and less than
20, the representation for a sparse frequency count must be used
instead. Here are the original histogram steps:

Step Weight Value
...
4 0.100000000 <= 17
5 0.400000000 <= 22
...

The following example shows the zero-weight step, step 5,
required for a sparse frequency count:

...
4 0.100000000 <= 17
5 0.000000000 < 20
6 0.350000000 = 20
7 0.050000000 <= 22
...

The operator for step 5 must be **<**. Step
6 must specify the weight for the value 20, and its operator must
be **=**.