<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/237166</link>
    <title>MATLAB Central Newsreader - fitting a Gamma cdf to my data</title>
    <description>Feed for thread: fitting a Gamma cdf to my data</description>
    <language>en-us</language>
    <copyright>&amp;copy;1994-2012 by MathWorks, Inc.</copyright>
    <webmaster>webmaster@mathworks.com</webmaster>
    <generator>MATLAB Central Newsreader</generator>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <ttl>60</ttl>
    <image>
      <title>MathWorks</title>
      <url>http://www.mathworks.com/images/membrane_icon.gif</url>
    </image>
    <item>
      <pubDate>Tue, 07 Oct 2008 19:46:01 -0400</pubDate>
      <title>fitting a Gamma cdf to my data</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/237166#604213</link>
      <author>Mohammad Monfared</author>
      <description>I'm interested in fitting a Gamma cdf to my data which looks like:&lt;br&gt;
particle_size=[2 50 ... 2000]&lt;br&gt;
particle_fraction=[0.08 0.2 ... 1]&lt;br&gt;
&lt;br&gt;
how can I do this jos?&lt;br&gt;
thanks,&lt;br&gt;
Reza</description>
    </item>
    <item>
      <pubDate>Wed, 08 Oct 2008 19:49:24 -0400</pubDate>
      <title>Re: fitting a Gamma cdf to my data</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/237166#604287</link>
      <author>Tom Lane</author>
      <description>&amp;gt; I'm interested in fitting a Gamma cdf to my data which looks like:&lt;br&gt;
&amp;gt; particle_size=[2 50 ... 2000]&lt;br&gt;
&amp;gt; particle_fraction=[0.08 0.2 ... 1]&lt;br&gt;
&lt;br&gt;
&amp;nbsp;Reza, the following demo contains a section showing one way to fit a gamma &lt;br&gt;
distribution:&lt;br&gt;
&lt;br&gt;
&lt;a href=&quot;http://www.mathworks.com/products/statistics/demos.html?file=/products/demos/shipping/stats/cdffitdemo.html&quot;&gt;http://www.mathworks.com/products/statistics/demos.html?file=/products/demos/shipping/stats/cdffitdemo.html&lt;/a&gt;&lt;br&gt;
&lt;br&gt;
The point of this demo is to offer an alternative to maximum likelihood &lt;br&gt;
estimation, especially in cases where mle doesn't work.&lt;br&gt;
&lt;br&gt;
If the variables you describe above are just a summary of some other data, &lt;br&gt;
and if you can get at that other data, I recommend you do that instead. &lt;br&gt;
Then you can use gamfit to get the maximum likelihood estimates.&lt;br&gt;
&lt;br&gt;
Even if you can't get raw data, you could maximize the likelihood based on &lt;br&gt;
this summary data.  Here's an example, where I generate some gamma data but &lt;br&gt;
retain only bin centers and cumulative frequencies.  I can use fminsearch to &lt;br&gt;
mimimize the negative log likelihood weighted by the frequencies.  The blue &lt;br&gt;
things are the raw data and a fit based on them, the red things are the &lt;br&gt;
binned data and a fit based on the bin frequencies.&lt;br&gt;
&lt;br&gt;
% Raw data with fit&lt;br&gt;
x = gamrnd(2,100,100,1);&lt;br&gt;
p1 = gamfit(x)&lt;br&gt;
&lt;br&gt;
% Summary data with fit&lt;br&gt;
[n,c] = hist(x);       % c = rounded data&lt;br&gt;
F = cumsum(n/sum(n));  % F = cumulative proportions&lt;br&gt;
f = diff([0,F]);       % f = proportions&lt;br&gt;
p2 = fminsearch(@(ab) -sum(f.*log(gampdf(c,ab(1),ab(2)))),[1,mean(c)])&lt;br&gt;
&lt;br&gt;
% How does it look?&lt;br&gt;
ecdf(x); line(xx,gamcdf(xx,p1(1),p1(2)),'linestyle',':')&lt;br&gt;
hold on; set(stairs(c,F),'color','r'); hold off&lt;br&gt;
line(xx,gamcdf(xx,p2(1),p2(2)),'color','r','linestyle',':')&lt;br&gt;
&lt;br&gt;
This doesn't give you any measures of uncertainty for the estimates.  But &lt;br&gt;
I'm not sure how I'd compute those anyway, given that you don't seem to have &lt;br&gt;
a notion of a &quot;sample size&quot; in your example.&lt;br&gt;
&lt;br&gt;
-- Tom </description>
    </item>
    <item>
      <pubDate>Thu, 09 Oct 2008 13:53:14 -0400</pubDate>
      <title>Re: fitting a Gamma cdf to my data</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/237166#604371</link>
      <author>aasim Azooz</author>
      <description>&quot;Mohammad Monfared&quot; &amp;lt;gohardoust@gmail.com&amp;gt; wrote in message &amp;lt;gcge9p$sfv$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; I'm interested in fitting a Gamma cdf to my data which looks like:&lt;br&gt;
&amp;gt; particle_size=[2 50 ... 2000]&lt;br&gt;
&amp;gt; particle_fraction=[0.08 0.2 ... 1]&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; how can I do this jos?&lt;br&gt;
&amp;gt; thanks,&lt;br&gt;
&amp;gt; Reza&lt;br&gt;
&lt;br&gt;
Dear Reza&lt;br&gt;
Can you tell me what do you mean by cdf? is it a Gamma function of some type I may help you&lt;br&gt;
Aasim Azooz</description>
    </item>
    <item>
      <pubDate>Thu, 09 Oct 2008 21:33:01 -0400</pubDate>
      <title>Re: fitting a Gamma cdf to my data</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/237166#604542</link>
      <author>Mohammad Monfared</author>
      <description>&quot;aasim Azooz&quot; &amp;lt;aasimazooz@yahoo.com&amp;gt; wrote in message &amp;lt;gcl2c9$i8$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Dear Reza&lt;br&gt;
&amp;gt; Can you tell me what do you mean by cdf? is it a Gamma function of some type I may help you&lt;br&gt;
&amp;gt; Aasim Azooz&lt;br&gt;
&lt;br&gt;
Hi,&lt;br&gt;
cdf is for Cumulative Density Function. &lt;br&gt;
my data are about soil particle size and their fraction in a sample. for a soil sample, I have:&lt;br&gt;
&lt;br&gt;
p_size=[2 50 106 250 500 1000 2000]&lt;br&gt;
p_fraction=[0.0300 0.1700 0.2790 0.7350 0.9210 0.9940 1.0020]&lt;br&gt;
&lt;br&gt;
which says e.g. 27.90% of our soil particles size is less than 106. I don't know how to prepare them for 'gamfit' function (if possible).&lt;br&gt;
as a graph:&lt;br&gt;
stairs([0 p_size],[p_fraction 1.0020])&lt;br&gt;
&lt;br&gt;
And thanks Tom, for your explanatory answer! &lt;br&gt;
thanks again,&lt;br&gt;
Reza,</description>
    </item>
  </channel>
</rss>

