Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.graphics.apps.gnuplot > #3570 > unrolled thread
| Started by | Thomas Wagner <thomas.wagner.marl@freenet.de> |
|---|---|
| First post | 2017-03-09 00:24 +0100 |
| Last post | 2017-03-13 00:39 +0100 |
| Articles | 3 — 2 participants |
Back to article view | Back to comp.graphics.apps.gnuplot
Compute histograms using the new bin option Thomas Wagner <thomas.wagner.marl@freenet.de> - 2017-03-09 00:24 +0100
Re: Compute histograms using the new bin option Ethan A Merritt <EAMerritt@gmail.com> - 2017-03-09 23:09 -0800
Re: Compute histograms using the new bin option Thomas Wagner <thomas.wagner.marl@freenet.de> - 2017-03-13 00:39 +0100
| From | Thomas Wagner <thomas.wagner.marl@freenet.de> |
|---|---|
| Date | 2017-03-09 00:24 +0100 |
| Subject | Compute histograms using the new bin option |
| Message-ID | <o9q3r3$k3t$1@news.albasani.net> |
Hallo everybody, the new bin option of the plot command is what I am using to make gnuplot compute histograms from data files (gnuplot 5.1 on Windows 7). The results I get don't match the results I get when I calculate the histogram manually (I also used R to verify my manual calculations). Please use the following link to download a zip file that contains data files, gnuplot script etc. The ReadMe file contains some more explanations. https://vesuvius.egnyte.com/dl/0PUnJCDhrU Help is very much appreciated: this new capability of gnuplot to compute histograms is very helpful for my application. Thanks in advance, Thomas
[toc] | [next] | [standalone]
| From | Ethan A Merritt <EAMerritt@gmail.com> |
|---|---|
| Date | 2017-03-09 23:09 -0800 |
| Message-ID | <o9tjam$lmu$1@dont-email.me> |
| In reply to | #3570 |
Thomas Wagner wrote:
> Hallo everybody,
>
> the new bin option of the plot command is what I am using to make
> gnuplot compute histograms from data files (gnuplot 5.1 on Windows 7).
> The results I get don't match the results I get when I calculate the
> histogram manually (I also used R to verify my manual calculations).
>
> Please use the following link to download a zip file that contains
> data files, gnuplot script etc. The ReadMe file contains some more
> explanations.
>
> https://vesuvius.egnyte.com/dl/0PUnJCDhrU
>
> Help is very much appreciated: this new capability of gnuplot to
> compute histograms is very helpful for my application.
>
> Thanks in advance,
> Thomas
Yeah, it's confusing. Clearly the documentation could be better,
and maybe gnuplot's procedure should be brought more into line
with that of R.
Here is how gnuplot operates.
When you request N bins for range [XMIN:XMAX] you get
N equal-width bins where bin 1 is centered about XMIN
and bin N is centered about XMAX. This is clearly a different
use of XMIN and XMAX than you were expecting and does not match
the R variables BINRANGEMIN BINRANGEMAX.
So in order to replicate the numbers you got from R you need
to find the midpoints of your first and last bins.
(4000-0)/50 = 80 for the total bin width, so the first and
last bins are centered at 40 and 3960.
set table 'gnuplot_bins.out'
plot '1.dat' using 1:(1) bins=50 binrange [40:3960]
unset table
Gnuplot's approach makes some sense if you use it to plot
the original data "with impulses" or "with boxes" because it
places the impulse or box for each bin at the center of the bin.
It may make less sense for other uses.
Ethan
[toc] | [prev] | [next] | [standalone]
| From | Thomas Wagner <thomas.wagner.marl@freenet.de> |
|---|---|
| Date | 2017-03-13 00:39 +0100 |
| Message-ID | <oa4m6n$m10$1@news.albasani.net> |
| In reply to | #3571 |
Ethan, thank you very much for your help: I now understand how to set the binrange to get proper results. I only used R to check my own calculations because I don't trust my mathematical capabilities very much. It was not my intention to create the impression that I want gnuplot to work in the same way like R does. Gnuplot does it the gnuplot way, R does it the R way. I am perfectly happy with this especially because I now know how to use gnuplot to compute histograms. If you like please use this link to download a zip file with a new script that uses you corrections and a corresponding plot. https://vesuvius.egnyte.com/dl/xN4hu4kofo This new plot shows a perfect match between the (new) gnuplot results and my EXCEL calculations. But the plot also shows different results obtained with R for bins 45 and 46. I will post another mail to the R forum asking about this (now I can use the gnuplot result to back me up). Again thanks for you help, Thomas
[toc] | [prev] | [standalone]
Back to top | Article view | comp.graphics.apps.gnuplot
csiph-web