Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Find frequency for non-binned, weighted data

Here is a tricky problem (or at least so I think). I need to create a histogram, but instead of having the data and it's frequency, I have repeated data (i.e. not binned) and some weight for each data.

One example:

Angle  | Weight    
90   ....  3/10     
93   ....  2/10   
180  ....  2/10    
180  ....  1/10    
95   ....  2/10    

I want to create a histogram with bin size 10. The y-values should be the sum of weighted frequencies for angles within a range. How can I do it? Preferably Mathematica or pseudocode...

like image 352
PFD Avatar asked Dec 15 '25 16:12

PFD


1 Answers

In Mathematica 9, you can do it using the WeightedData function like this:

Histogram[WeightedData[{90, 93, 180, 180, 95}, {3/10, 2/10, 2/10, 1/10, 2/10}], {10}]

You should then get a graphic like this one:

Weighted Histogram

like image 103
Luxspes Avatar answered Dec 18 '25 07:12

Luxspes



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!