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

Curve fitting to get gamma curve parameter

Asked by Putra A on 6 Apr 2013

Dear Forum Member.

I want to fit a curve to gamma like curve with current data that i have.

i need to get shape and scale parameter from the data that i assume have a gamma intensity curve.

Here is the grey level as (Y)

Columns 1 through 17
150  149  151  157  163  169  174  176  177  177  177  181  185  186  185  184  181
Columns 18 through 24
176  173  171  169  167  168  168

and the index is

Columns 1 through 14
   1     2     3     4     5     6     7     8     9    10    11    12    13    14
Columns 15 through 24
  15    16    17    18    19    20    21    22    23    24

if i create the plot it will be like this

i want to assume the graph as gamma curve, how to get the shape and scale parameter for this curve if i only have x and y ?

new image :

Thank you :)

0 Comments

Putra A

Products

No products are associated with this question.

2 Answers

Answer by Tom Lane on 9 Apr 2013
Accepted answer

I'm not sure what you mean by a gamma curve. If you mean a scalar multiple of a curve with the same form as a gamma probability density function, here's an example using nlinfit from the Statistics Toolbox:

function main
y = [150  149  151  157  163  169  174  176  177  177  177  181 ...
     185  186  185  184  181  176  173  171  169  167  168  168];
x = 1:24;
p = nlinfit(x,y,@f,[1 10 150])
plot(x,y,'bo',x,f(p,x),'r-')
end
function y = f(abc,x)
a = abc(1); b = abc(2); c = abc(3);
y = c * x.^(a-1) .* exp(-x/b) / (b^a * gamma(a));
end

3 Comments

Putra A on 9 Apr 2013

Dear Tom Lane, Thank you for the answer :D.. yes what i want to do is to find the parameter for the curve which have same form with gamma pdf.

I am updated the image there i want to get gamma parameter for the red plot. How do you think about that Tom ? can i use your code above to have it done ?

Tom Lane on 9 Apr 2013

You can use the X and Y value for the red curve, in place of the X and Y values in your original posting.

Putra A on 10 Apr 2013

Ok nice, thank you for the answer tom :)

Tom Lane
Answer by bym on 6 Apr 2013

If you have the statistics toolbox, you can use:

 gamfit()

2 Comments

Putra A on 6 Apr 2013

thanks for your answer proecsm, but when i use gamfit(), isnt it used to determine scale and shape parameter from gamma distributed data ? while i only have a curve that i assume follow gamma curve not distribution.

bym on 7 Apr 2013

Yes, I thought your question pertained to statistics not image processing. You can use

lsqcurvefit()

to fit a nonlinear curve, but it appears from your plot that your data does not follow a power law

bym

Contact us