visualdatatools.com Forum Index visualdatatools.com
Discussion for DataTank and DataGraph
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Fitting a histogram

 
Post new topic   Reply to topic    visualdatatools.com Forum Index -> Request Fit Function
View previous topic :: View next topic  
Author Message
ijstokes



Joined: 27 Jan 2010
Posts: 24

PostPosted: Thu Jul 15, 2010 8:59 pm    Post subject: Fitting a histogram Reply with quote

I have a histogram and I want to fit a curve to it. I imagine this is possible, but I'm having trouble figuring out how to do this.
_________________
Ian Stokes-Rees
Harvard Medical School
Back to top
View user's profile Send private message
grumpy_labrat



Joined: 03 Aug 2008
Posts: 170
Location: University of Oregon

PostPosted: Thu Jul 15, 2010 10:55 pm    Post subject: Reply with quote

Could you post an image so we can see what you are trying to fit?
Back to top
View user's profile Send private message AIM Address
ijstokes



Joined: 27 Jan 2010
Posts: 24

PostPosted: Fri Jul 16, 2010 12:12 am    Post subject: Reply with quote

Here's an example:

http://dl.dropbox.com/u/1561496/histogram-fit.png

For this one, obviously the fitted curve should be a gaussian. For other curves, I want poisson distributions, or exponential decays, etc., to fit a histogram of a sampled population.

The short story is that I'd want the curves to be fit to the bin heights, with some scaling for bin size and number of samples.

Ian
_________________
Ian Stokes-Rees
Harvard Medical School
Back to top
View user's profile Send private message
grumpy_labrat



Joined: 03 Aug 2008
Posts: 170
Location: University of Oregon

PostPosted: Fri Jul 16, 2010 10:13 am    Post subject: Reply with quote

K, this is going to be a bit ugly, but as near as I can tell there isn't any "easy" way to this. (David can correct me later if there is something I missing).

You'll need to look up the functions for the distribution that you are interested in fitting, but the problem here is that the histogram takes 1D data and assigns a second dimension (bins) based on the statistical analysis. The histogram function has a little gear button next to the statistics window that gives you access to the the data set for the histogram (i.e. your data sorted into bins). To get the data do the following:

1. Click the gear button, select "copy histogram information to columns."
2. cmd-d to pull up the definitions menu.
3. cmd-v to paste two new columns with the names "location" and "value."

These new columns are your x and y (respectively) for the histogram. They should be centered on the center of the top edge each bin of the histogram. Next it would just be a matter of fitting this data set to your desired distribution via a "fit" module set to arbitrary function mode, and using your desired distribution. Formula for most of the common ones can be found on Wikipedia.

Hope that helps.
Back to top
View user's profile Send private message AIM Address
Display posts from previous:   
Post new topic   Reply to topic    visualdatatools.com Forum Index -> Request Fit Function All times are GMT - 3 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group