Firstly, thank you very much for your reply. I went looking for a solution to this problem on a few different messageboards, including stackoverflow.com. One of the members there was kind enough to explain how to go about solving this problem. I'll post it below in case anyone else runs into the same problem.
The mean is A*B. So can you solve for perhaps A in terms of the mean(mu) and B?
- Code: Select all
A = mu/B
Of course, this does no good unless you knew B. Or does it?
Look at your first expression. Can you substitute?
- Code: Select all
gamcdf(2.11, mu/B, B) - gamcdf(1.61, mu/B, B) = 0.90
Does this get you any closer? Perhaps. There will be no useful symbolic solution available, except in terms of the incomplete gamma function itself. How do you solve a single equation numerically in one unknown in matlab? Use fzero.
Of course, fzero looks for a zero value. But by subtracting 0.90, that is resolved.
Can we define a function that fzero can use? Use a function handle.
- Code: Select all
>> mu = 1.86;
>> gamfun = @(B) gamcdf(2.11, mu/B, B) - gamcdf(1.61, mu/B, B) - 0.90;
So try it. Before we do that, I always recommend plotting things.
- Code: Select all
>> ezplot(gamfun)

Hmm. That plot suggests that it might be difficult to find a zero of your function. If you do try it, you will find that good starting values for fzero are necessary here.
Sorry about my first try. Better starting values for fzero, plus some more plotting does give a gamma distribution that yields the desired shape.
- Code: Select all
>> B = fzero(gamfun,[.0000001,.1])
B =
0.0124760672290871
>> A = mu/B
A =
149.085442218805
>> ezplot(@(x) gampdf(x,A,B))

In fact this is a very "normal", i.e, Gaussian, looking curve.