From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

histogram

Solved!
Go to solution

Hi

 

I try to generate a histogram from oscilloscope data. The data is some sort of noise. The problem is, that the data is already bin-ed by the oscilloscope, and the binning is not constant. If I then use a histogram, the output will be much dependent on the binning in the histogram. If I e.g. set the binning wrong, I might not see some peaks or I might see a drop somewhere, just because one bin of the histogram counts 2 bins of the oscilloscope, and the other one 3 bins of the oscilloscope. I later on fit a Gaussian to the histogram.

 

My question: Is there a way to make a histogram out of the data that I get directly from oscilloscope, without assigning bins? And can I still fit my Gaussian to the data?

Best Regards,

Lorenz

 

Edit: So I want to basically circumvent the problem of interference between the 2 binnings.

0 Kudos
Message 1 of 10
(3,587 Views)

hi,


what result would you expect for a histogram with no bins?

 

 

could show some sample data?

 

 

 

Regards,
Alex

0 Kudos
Message 2 of 10
(3,555 Views)

Hi Alex,

 

I append a data set and a histogram of what I mean (the histogram is not from this exact dataset, but it does not matter). You can clearly see that about every second bin is smaller than the adjecent ones. This is like trying to equally sort 5 apples in 2 bins.

 

Histogram problem

 

best,

 

Lorenz

Download All
0 Kudos
Message 3 of 10
(3,536 Views)

You can clearly see that about every second bin is smaller than the adjecent ones

 


I assume you don't talk about the bins' width, don't you?

 

Is the red curve meant to be the white bins' cumulative histogram ?

 

 

 

Setting the right number of bins is not a trivial task; but there do exist some heuristics e.g. number of bins = sqaureroot(number of data-points)

 

If you want to display the data points distribution without bins you could use a scatter plot instead, like this:

 

1.PNG    2.PNG

 

 

Regards,
Alex 

 

 

0 Kudos
Message 4 of 10
(3,523 Views)

@alexderjuengere wrote:

You can clearly see that about every second bin is smaller than the adjecent ones

 


I assume you don't talk about the bins' width, don't you?

 


Exactly, not the width. I talk about the height. Sorry for beeing so unprecise...

 


@alexderjuengere wrote:

 

Is the red curve meant to be the white bins' cumulative histogram ?


 


No, the red curve is some fit that I apply to my histogram data. If you are interested, it yields the linewidth of a laser that passed through a cavity. But you don't have to care about that 😉


@alexderjuengere wrote:

 

Setting the right number of bins is not a trivial task; but there do exist some heuristics e.g. number of bins = sqaureroot(number of data-points)

 

 



Yes, true. That is good to know, thank you. In my case, I have an oscilloscope with 8 bit resolution, and 2500 data points per sample, so I do already have some binning. Unfortunately, the oscilloscope's binning is a bit weird, I did not manage to simply use the same amount of bins at the same positions.

 

So I do already have the data binned in a way, that I am fine with (and statistics gets better when I accumulate several samples a 2500 data points).

 

The solution with the scatter plot might work, I have to look into that now 🙂 I'll write again, when I know more.

 

Thank you so far!

0 Kudos
Message 5 of 10
(3,512 Views)

Alright, I am not sure if the scatter plot you show is what I am looking for. On the left, you show the data, on the right a histogram. That is what I have at the moment too. If you look at the data on the left, you can already see horizontal lines in the data, the data is already binned on discrete values. I would now like to accumulate all data points with the same value and get a distribution out of that. So, a histogram without binning again.

0 Kudos
Message 6 of 10
(3,509 Views)
Solution
Accepted by topic author Chekhov

I would now like to accumulate all data points with the same value and get a distribution out of that.


ok, now I understand! I would call it a histogram without extra-binning:

 

2013-07-25_binning.png

0 Kudos
Message 7 of 10
(3,484 Views)

So, your oscilloscope is giving you data with a minimum of 0 and a maximum of 255 (256 total bins), if I understand you correctly. If you create a histogram with these bins or an even fraction of them (2, 4, 8, 16, 32, 64, or 128), you should get an unbiased plot. Otherwise, yes, you will get unsatisfying results.

 

These are from the sample data you posted (I just used Excel to plot this demo), the first with bins of 0.04 (half the resolution of your data set) and the second with bins of 0.05 (40% of the resolution of your data set, not an even multiple).

 

 

bin_0.004.png     bin_0.005.png

 

Cameron

To err is human, but to really foul it up requires a computer.
The optimist believes we are in the best of all possible worlds - the pessimist fears this is true.
Profanity is the one language all programmers know best.
An expert is someone who has made all the possible mistakes.

To learn something about LabVIEW at no extra cost, work the online LabVIEW tutorial(s):

LabVIEW Unit 1 - Getting Started</ a>
Learn to Use LabVIEW with MyDAQ</ a>
0 Kudos
Message 8 of 10
(3,475 Views)

@Alex: Thanks, that is exactly what I was looking for, now I have to understand it ^^ (I am quite new to LabView, but I am willing to learn)

 

@Camerond: I thought the same, but it does not work with most of my data. Maybe the one file I attached was one of those that worked. I have to say that I did not dig deeper into the why it doesn't work, as I see that it doesn't 😉 So I will try the approach of Alex, which circumvents the whole binning issue.

 

Thanks for the help guys, especially Alex!

0 Kudos
Message 9 of 10
(3,459 Views)

And its working 🙂 Thanks a lot again!!!

0 Kudos
Message 10 of 10
(3,447 Views)