# Configuring a Relative Frequency Histogram with Normalized Counts per Year?

## Recommended Posts

I have a signal where I'd like to compare the distributions in 2021 vs. 2022 using a histogram, but with the normalized counts per year (counts divided by total counts in that year, or relative frequency histogram) instead of just the raw counts.

Is there an easy way to configure this in Seeq?

• 1
##### Share on other sites

• Seeq Team

Hi Siang Lim,

This is one way I could think of.

Step 1: Calculate Total Count (Yearly)

Step 2: Calculate the normalized count for each bin. Example here is for bin 85-90. Repeat the step for all your bins.

```\$signal
.within(\$signal.isbetween(85,90))
.aggregate(count(),\$yearly, startKey())
.toDiscrete()
.divide(\$total_yearly_count)```

Step 3: Combine all the normalized count for all the bins and move it as example below.

```combinewith(
\$nc95.move(1min),
\$nc90.move(2min),
\$nc85.move(3min)
)```

Step 4: Create the conditions and set property.

```\$ref = \$y.afterStart(1.1min)

combinewith(
\$ref.move(1min,0).setProperty('Bin','95-100'),
\$ref.move(2min,1min).setProperty('Bin','90-95'),
\$ref.move(3min,2min).setProperty('Bin','85-90')
)```

Note: Ensure the move settings are aligned with the above step. For example, the normalized for bin 90-95 is moved at 2 minutes at step 3 and step 4.

Step 5: Create the histogram.

Edited by Nuraisyah Rosli
##### Share on other sites

On 3/10/2022 at 9:52 PM, Nuraisyah Rosli said:

Hi Siang Lim,

This is one way I could think of.

Step 1: Calculate Total Count (Yearly)

Step 2: Calculate the normalized count for each bin. Example here is for bin 85-90. Repeat the step for all your bins.

```\$signal
.within(\$signal.isbetween(85,90))
.aggregate(count(),\$yearly, startKey())
.toDiscrete()
.divide(\$total_yearly_count)```

Step 3: Combine all the normalized count for all the bins and move it as example below.

```combinewith(
\$nc95.move(1min),
\$nc90.move(2min),
\$nc85.move(3min)
)```

Step 4: Create the conditions and set property.

```\$ref = \$y.afterStart(1.1min)

combinewith(
\$ref.move(1min,0).setProperty('Bin','95-100'),
\$ref.move(2min,1min).setProperty('Bin','90-95'),
\$ref.move(3min,2min).setProperty('Bin','85-90')
)```

Note: Ensure the move settings are aligned with the above step. For example, the normalized for bin 90-95 is moved at 2 minutes at step 3 and step 4.

Step 5: Create the histogram.

Thanks for the suggestion @Nuraisyah Rosli, is there a way to automate the creation of the bins instead of defining them manually?

I'd like to generate the histogram for 10+ assets, but they all have different numeric ranges (e.g. some are 0-10, some 0-100).