From: Tim on
Hello,

I have two columns of data, one with a distance where a mass is located and the other with the mass that is located there. I want to figure out a mass distribution from this data.

I was thinking to do a histogram where basically the distance was the x axis and the count was a sum of the masses, as I believe this would give me the right curve that would just need some scaling to be the correct distribution.

Does anyone have any suggestions on how to do this, or any suggestions on a better method?

Thank you!
From: Walter Roberson on
Tim wrote:

> I have two columns of data, one with a distance where a mass is located
> and the other with the mass that is located there. I want to figure out
> a mass distribution from this data.

No direction information?? It seems to me that having a mass located 5
units along X and a second at 5 units along Y, would be a quite
different "distribution" than what could be derived from just knowing
you had two masses each 5 units away.
From: Tim on
Walter Roberson <roberson(a)hushmail.com> wrote in message <M4Z3o.3891$mW5.1160(a)newsfe14.iad>...
> Tim wrote:
>
> > I have two columns of data, one with a distance where a mass is located
> > and the other with the mass that is located there. I want to figure out
> > a mass distribution from this data.
>
> No direction information?? It seems to me that having a mass located 5
> units along X and a second at 5 units along Y, would be a quite
> different "distribution" than what could be derived from just knowing
> you had two masses each 5 units away.

No, no direction information. It's a radial distance with spherical symmetry.
From: Walter Roberson on
Tim wrote:

> I have two columns of data, one with a distance where a mass is located
> and the other with the mass that is located there. I want to figure out
> a mass distribution from this data.
>
> I was thinking to do a histogram where basically the distance was the x
> axis and the count was a sum of the masses, as I believe this would give
> me the right curve that would just need some scaling to be the correct
> distribution.
> Does anyone have any suggestions on how to do this, or any suggestions
> on a better method?


A histogram inherently only counts the _number_ of occurrences, not their weight.

maxx = max(data(:,1));
minx = min(data(:,1));
numbins = 25; %whatever is appropriate

binno = 1 + floor((data(:,1) - minx) * numbins / (maxx - minx));

massdistribution = accumarray(binno, data(2,:));
bar(massdistribution);