# Curve fitting to get gamma curve parameter

조회 수: 39(최근 30일)
Putra A 2013년 4월 6일
댓글: Torsten 2018년 3월 6일
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 :)

댓글을 달려면 로그인하십시오.

### 채택된 답변

Tom Lane 2013년 4월 9일
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표시숨기기 이전 댓글 수: 2
Putra A 2013년 4월 10일
Ok nice, thank you for the answer tom :)

댓글을 달려면 로그인하십시오.

### 추가 답변(2개)

bym 2013년 4월 6일
If you have the statistics toolbox, you can use:
gamfit()
##### 댓글 수: 2표시숨기기 이전 댓글 수: 1
bym 2013년 4월 7일
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

댓글을 달려면 로그인하십시오.

Shariefa Shaik 2018년 3월 6일
Why [1 10 150] values only
##### 댓글 수: 1표시숨기기 없음
Torsten 2018년 3월 6일
These are initial guesses for the parameters to be determined, not data points.

댓글을 달려면 로그인하십시오.

### 범주

Find more on Gamma Functions in Help Center and File Exchange

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by