# JointHistogram with non-normalized output

Thu, 01/19/2023 - 01:41 am

- see the last comments. Ended up being quite trivial and should also work if outliers are excluded (I think - I have not tested with outliers though) End edit.Edit: Solved

Dear all

I am using JointHistogram to create a 2D image using two waves with x- and y-coordinates. This works like a charm but I run into one minor problem that should be easy to solve but I cannot figure it out.

The documentation for JointHistogram states:

"When outliers are excluded the output wave sums to 1. When they are included the sum of the output wave is smaller by the ratio of the number of outliers to the total number of points in the histogram."

In my data I have no outliers, so the output will sum to 1.

However, I would like to scale this so that it scales to the actual number of "counts" in each bin. This way the output 2D image will correspond to the actual number of "counts" I have in each bin. I cannot see a flag for this, nor can I right now see how to get this multiplication-factor from the raw x-y-data waves...

I hope that someone has solved this already...

Best,

Johan S

Without thinking this through fully, wouldn't the scaling factor be just the sum of your input x,y data divided by the number of bins? After all, you have used

allcounts and the output from JointHistogram represents the relative distribution of these counts into each bin, right?January 19, 2023 at 01:50 am - Permalink

In reply to Without thinking this… by chozo

I think you are correct... I will try - thanks!

January 19, 2023 at 02:05 am - Permalink

Actually, thinking again I was under the impression that your highest bin is 1, but reading again you say that the sum (area) of the output is 1. Then, I think the scaling factor should just be the sum of your input data (without dividing by the number of bins), because then you get sum of input = sum of histogram.

January 19, 2023 at 02:09 am - Permalink

In reply to Actually, thinking again I… by chozo

I think that since each x-y-coordinate corresponds to a count then I think that the following code-snippet will work.

At least this is what I think will work... Note that I do not use the sum, but rather the number of points... Thanks a lot for your input (again :)

JointHistogram /BINS={v_bins_Column_0, v_bins_Column_1, 0, 0} /C /DEST=$s_temp /P=0 w_data_x, w_data_y

wave w_JointHistogram_Output = $s_temp

w_JointHistogram_Output *= numpnts(w_data_x) //This scales the "normalized" image to the actual number of counts. See https://www.wavemetrics.com/forum/general/jointhistogram-non-normalized…

January 19, 2023 at 02:45 am - Permalink

FWIW: In response to this thread, JointHistogram in IP10 uses automatic multithreading for the 1D and 2D analysis.

January 20, 2023 at 11:38 am - Permalink