Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

To resolve issues starting MATLAB on Mac OS X 10.10 (Yosemite) visit: http://www.mathworks.com/matlabcentral/answers/159016

How to fit histogram data with normfit using signed X-axis ?

Asked by Octopode on 16 Jan 2013

Hi,

I'm puzzled with normfit.

I have intensity of velocity data on a given X-direction, converted as a 1-D vector Vx. It has a size of S= 256 X 256 elements (65536) elements. They are signed values, of the order of 10^-2.

No problem with dfittool. I get sensible values for mean and standard deviation. But i need to automate the process, for batch processing. No GUI. Thus, thought i used normfit to fit a PDF. 1) Is this the right way to go ? Is normfit designed to fit a PDF with signed bins values ?

I thought i'd output the histogram data and built the PDF from there : So i did :

[nVx,Vxbins]=hist(Vx,nbins) 

Then to obtain pdf i did :

pdf = nVx ./ (S*diff(Vxbins(1:2)))

A posteriori, i checked that actually sum(nVx) = S = 65336 (makes sense to me)

From there, not sure i should normalize to the max... does normfit require that ? My max value in the pdf is about 15.

From there, i do

[mu , sigma, blah...] = normfit(pdf)

Result is crap, i get something completely different from dfittool.

What am i missing ? Is normfit not designed for this situation ? If not, what is the right way to go ?

Thanks

0 Comments

Octopode

Products

No products are associated with this question.

3 Answers

Answer by Sarah Wait Zaranek on 16 Jan 2013
Accepted answer

Probably the easiest way to handle this, if you like what the distribution fitting tool is doing, is to autogenerate code from the tool itself. You can do that via File -> Generate Code. That will allow you to do batch processing.

1 Comment

Octopode on 16 Jan 2013

I wouldn't mind doing that on last resort. However, doing the "generate code" is to be done manually once, and applies only to my code. Batch processing would not be possible if the code/context changes as i would need to "re-generate" the diftool-related code. If i read whatever code is generated, i eventually will find what exactly dfittool is doing but normfit is meant to avoid that pain I guess...

Sarah Wait Zaranek
Answer by owr on 16 Jan 2013

You should be calling normfit on the raw data vector itself, not your pdf approx:

[mu , sigma, blah...] = normfit(Vx)

1 Comment

Octopode on 16 Jan 2013

Ok !! I thought i already tried that at first before going for the fit of the pdf. Obviously i didn't try properly. It works now, using Vx instead of the histogram output. That was really simple indeed, i feel a bit stupid. Thanks

owr
Answer by Octopode on 16 Jan 2013
Edited by Octopode on 16 Jan 2013

Thank you for your answer. I just tried generating the code. I found out that they are using fitdist in a way i didn't use before. They are not using directly normfit. So i assume normfit is more low level and assumes X to be positive (while my data are signed), although the help doesn't say anything about that. So, using fitdist is much easier and answers my question, although the use of normfit stays really obscure. (concerning the domain for X...)

0 Comments

Octopode

Contact us