<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic how to calculate the distribution function of the Gamma(a,b) law then to calculate F(k), F(k-1),etc. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/how-to-calculate-the-distribution-function-of-the-Gamma-a-b-law/m-p/797362#M287467</link>
    <description>&lt;P&gt;I need to create a cumulative distribution function (F) of the Gamma(a,b) distribution and then use this function to calculate Ws which I have noted profil_W in my program.&lt;BR /&gt;Here is the calculation formula for profil_W.&lt;/P&gt;&lt;P&gt;Profile_W=(k*F(k)+(k-2)*F(k-2))+(k-1)*F(k-1)+ab(2*F(k-1)-F( k-2)-F(k)).&lt;BR /&gt;The first part F follows the Gamma(a,b) law and the second part F follows the Gamma(a+1,b) law.&lt;BR /&gt;Note that the second part begins with ab(...).&lt;/P&gt;&lt;P&gt;Here is the code to calculate the 2 laws of Gamma followed by F that I noted "Fct_ab" the first and "Fct_A1b" the second.&lt;BR /&gt;k represents "Incid" in my formula. My problem is that I can't vary or calculate the functions F(k), F(k-1), F(k-2), etc.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/*----------------------------------------------*/&lt;BR /&gt;proc contents date= tab_It;&lt;BR /&gt;run;&lt;BR /&gt;/*Fixed Gamma Law Parameter*/&lt;BR /&gt;%let a=1;&lt;BR /&gt;%let b=5;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;/*Distribution of the Gamma(a,b) distribution*/&lt;BR /&gt;Data tab_W;&lt;BR /&gt;set tab_It;&lt;BR /&gt;if (%sysevalf(&amp;amp;b.)&amp;gt;0) and (%sysevalf(&amp;amp;b.)&amp;gt;0) ;&lt;BR /&gt;if (Incid &amp;gt;0);&lt;BR /&gt;Fct_ab=RAND('GAMMA', %sysevalf(&amp;amp;a.), %sysevalf(&amp;amp;b.));&lt;BR /&gt;Fct_A1b=RAND('GAMMA', %sysevalf(&amp;amp;a.)+1, %sysevalf(&amp;amp;b.));&lt;BR /&gt;profil_W=round((Incid*(Fct_ab)+(Incid-2)*Fct_ab-2*(Incid-1)*Fct_ab) +%sysevalf(&amp;amp;a.)*%sysevalf(&amp;amp;b.)*(2*Fct_A1b-Fct_A1b),0.01);&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
    <pubDate>Sat, 19 Feb 2022 05:57:19 GMT</pubDate>
    <dc:creator>Gick</dc:creator>
    <dc:date>2022-02-19T05:57:19Z</dc:date>
    <item>
      <title>how to calculate the distribution function of the Gamma(a,b) law then to calculate F(k), F(k-1),etc.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-calculate-the-distribution-function-of-the-Gamma-a-b-law/m-p/797362#M287467</link>
      <description>&lt;P&gt;I need to create a cumulative distribution function (F) of the Gamma(a,b) distribution and then use this function to calculate Ws which I have noted profil_W in my program.&lt;BR /&gt;Here is the calculation formula for profil_W.&lt;/P&gt;&lt;P&gt;Profile_W=(k*F(k)+(k-2)*F(k-2))+(k-1)*F(k-1)+ab(2*F(k-1)-F( k-2)-F(k)).&lt;BR /&gt;The first part F follows the Gamma(a,b) law and the second part F follows the Gamma(a+1,b) law.&lt;BR /&gt;Note that the second part begins with ab(...).&lt;/P&gt;&lt;P&gt;Here is the code to calculate the 2 laws of Gamma followed by F that I noted "Fct_ab" the first and "Fct_A1b" the second.&lt;BR /&gt;k represents "Incid" in my formula. My problem is that I can't vary or calculate the functions F(k), F(k-1), F(k-2), etc.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/*----------------------------------------------*/&lt;BR /&gt;proc contents date= tab_It;&lt;BR /&gt;run;&lt;BR /&gt;/*Fixed Gamma Law Parameter*/&lt;BR /&gt;%let a=1;&lt;BR /&gt;%let b=5;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;/*Distribution of the Gamma(a,b) distribution*/&lt;BR /&gt;Data tab_W;&lt;BR /&gt;set tab_It;&lt;BR /&gt;if (%sysevalf(&amp;amp;b.)&amp;gt;0) and (%sysevalf(&amp;amp;b.)&amp;gt;0) ;&lt;BR /&gt;if (Incid &amp;gt;0);&lt;BR /&gt;Fct_ab=RAND('GAMMA', %sysevalf(&amp;amp;a.), %sysevalf(&amp;amp;b.));&lt;BR /&gt;Fct_A1b=RAND('GAMMA', %sysevalf(&amp;amp;a.)+1, %sysevalf(&amp;amp;b.));&lt;BR /&gt;profil_W=round((Incid*(Fct_ab)+(Incid-2)*Fct_ab-2*(Incid-1)*Fct_ab) +%sysevalf(&amp;amp;a.)*%sysevalf(&amp;amp;b.)*(2*Fct_A1b-Fct_A1b),0.01);&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 19 Feb 2022 05:57:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-calculate-the-distribution-function-of-the-Gamma-a-b-law/m-p/797362#M287467</guid>
      <dc:creator>Gick</dc:creator>
      <dc:date>2022-02-19T05:57:19Z</dc:date>
    </item>
    <item>
      <title>Re: how to calculate the distribution function of the Gamma(a,b) law then to calculate F(k), F(k-1),</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-calculate-the-distribution-function-of-the-Gamma-a-b-law/m-p/797403#M287501</link>
      <description>&lt;P&gt;If a macro variable contains a value that is easily considered as a number you do not need all that %syseval junk.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;PRE&gt;%let a= 0.25;
%let b= 4;


data example;
   x = &amp;amp;a. * &amp;amp;b.;
run;&lt;/PRE&gt;
&lt;P&gt;which results in the expected 1 for x. All macro variables are is text. If the value you have would be okay for a statement as is such as : x = 0.25 * 4 ; then that's all you need.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The function CDF in SAS returns a value from the cumulative distribution, the Quantile function returns a specific point from the distribution. Rand generates a random number from from the distribution so I doubt that is what you want.&lt;/P&gt;
&lt;P&gt;"Generate a distribution" I would typically take to create fair portion of values from a distribution, not a single value as your code does. So I suspect that you need to provide more details. Possibly provide a link to what you mean by "Gamma law" as most of the internet search results I get are company names, gaming or image color correction related.&lt;/P&gt;</description>
      <pubDate>Sat, 19 Feb 2022 18:28:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-calculate-the-distribution-function-of-the-Gamma-a-b-law/m-p/797403#M287501</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-02-19T18:28:18Z</dc:date>
    </item>
    <item>
      <title>Re: how to calculate the distribution function of the Gamma(a,b) law then to calculate F(k), F(k-1),</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-calculate-the-distribution-function-of-the-Gamma-a-b-law/m-p/797409#M287506</link>
      <description>Here is the link that explains the gamma distribution. Source wikipedia. &lt;A href="https://en.wikipedia.org/wiki/Gamma_distribution" target="_blank"&gt;https://en.wikipedia.org/wiki/Gamma_distribution&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;For the macro variables created, I tried to fix values ​​of a and b which are the parameters of the "gamma law". Once the calculation of the repartition function is good. I could change its parameter values.&lt;BR /&gt;&lt;BR /&gt;In my code, I used %sysevalf() but the problem is to know if the calculation of my distribution functions are well calculated and also the profil_W variable.&lt;BR /&gt;Thank you for your comments and I am still on my hunger</description>
      <pubDate>Sat, 19 Feb 2022 19:40:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-calculate-the-distribution-function-of-the-Gamma-a-b-law/m-p/797409#M287506</guid>
      <dc:creator>Gick</dc:creator>
      <dc:date>2022-02-19T19:40:11Z</dc:date>
    </item>
    <item>
      <title>Re: how to calculate the distribution function of the Gamma(a,b) law then to calculate F(k), F(k-1),</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-calculate-the-distribution-function-of-the-Gamma-a-b-law/m-p/797411#M287508</link>
      <description>Here is the link of a course that better explains the Gamma Law : &lt;A href="https://www.probabilitycourse.com/chapter4/4_2_4_Gamma_distribution.php" target="_blank"&gt;https://www.probabilitycourse.com/chapter4/4_2_4_Gamma_distribution.php&lt;/A&gt;&lt;BR /&gt;</description>
      <pubDate>Sat, 19 Feb 2022 19:50:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-calculate-the-distribution-function-of-the-Gamma-a-b-law/m-p/797411#M287508</guid>
      <dc:creator>Gick</dc:creator>
      <dc:date>2022-02-19T19:50:08Z</dc:date>
    </item>
    <item>
      <title>Re: how to calculate the distribution function of the Gamma(a,b) law then to calculate F(k), F(k-1),</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-calculate-the-distribution-function-of-the-Gamma-a-b-law/m-p/797439#M287534</link>
      <description>&lt;P&gt;Time to start over. I know what a Gamma distribution is. Neither of the links you provide have anything related to "Gamma &lt;U&gt;&lt;STRONG&gt;Law&lt;/STRONG&gt;&lt;/U&gt;"&lt;/P&gt;
&lt;P&gt;Your request starts with&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;I need to create a cumulative distribution function (F) of the Gamma(a,b) distribution and then use this function to calculate&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;STRONG&gt;You&lt;/STRONG&gt; do not need to create a CDF for the gamma function. SAS provides two functions, one of which is very likely what you want either CDF or QUANTILE.&lt;/P&gt;
&lt;P&gt;CDF would involve writing code to implement and calculate integrals. Which you have not shown even a slight attempt to do so. I have done such code but refuse to do for functions that SAS Provides and except for nearly-trivial examples wouldn't on this forum as the amount of work is excessive for a volunteer.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Look at the documentation for the CDF function,&amp;nbsp;&lt;/P&gt;
&lt;DIV class="xis-refDictEntry"&gt;
&lt;P class="xis-shortDescription"&gt;Returns a value from a cumulative probability distribution.&lt;/P&gt;
&lt;DIV class="xis-refDictEntry"&gt;
&lt;DIV class="xis-details"&gt;
&lt;DIV id="p0gv6ljmxqymx2n1ov0qghasp0al" class="xis-subTopic"&gt;
&lt;DIV id="p1ngy11ll46n03n11l0v69wm68td" class="xis-topicContent"&gt;
&lt;DIV class="xis-syntaxSimple"&gt;
&lt;DIV class="xis-syntaxLevel"&gt;&lt;SPAN class="xis-keyword"&gt;CDF&lt;/SPAN&gt;('GAMMA', &lt;SPAN class="xis-userSuppliedSyntaxValue"&gt;&lt;A title="Description of syntax: x" href="http://127.0.0.1:50353/help/lefunctionsref.hlp/n0n7cce4a3gfqkn1vr0p1x0of99s.htm#n080jzuf3rk7iln1dswzlhjushgo" target="_blank"&gt;x&lt;/A&gt;&lt;/SPAN&gt;, &lt;SPAN class="xis-userSuppliedSyntaxValue"&gt;&lt;A title="Description of syntax: a" href="http://127.0.0.1:50353/help/lefunctionsref.hlp/n0n7cce4a3gfqkn1vr0p1x0of99s.htm#n1595blwzsn3ggn166h84frpn9kj" target="_blank"&gt;a&lt;/A&gt;&lt;/SPAN&gt; &lt;SPAN class="xis-argOptional"&gt;&amp;lt;, &lt;SPAN class="xis-userSuppliedSyntaxValue"&gt;&lt;A title="Description of syntax: λ" href="http://127.0.0.1:50353/help/lefunctionsref.hlp/n0n7cce4a3gfqkn1vr0p1x0of99s.htm#n0adlgfuq9rrwun1smjwnn0hpasv" target="_blank"&gt;λ&lt;/A&gt;&lt;/SPAN&gt;&amp;gt;&lt;/SPAN&gt;)&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;DIV class="xis-refDictEntry"&gt;
&lt;DIV class="xis-details"&gt;
&lt;DIV id="p0gv6ljmxqymx2n1ov0qghasp0al" class="xis-subTopic"&gt;
&lt;DIV id="p1ngy11ll46n03n11l0v69wm68td" class="xis-topicContent"&gt;
&lt;DIV id="p1dc7y92giacj4n1agkfoczo99ru" class="xis-paragraph"&gt;The CDF function for the gamma distribution returns the &lt;STRONG&gt;probability&lt;/STRONG&gt; that an observation from a gamma distribution, with the shape parameter &lt;SPAN class="xis-userSuppliedValue"&gt;a&lt;/SPAN&gt; and the scale parameter λ, is less than or equal to &lt;SPAN class="xis-userSuppliedValue"&gt;x&lt;/SPAN&gt;.&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P class="xis-shortDescription"&gt;&amp;nbsp; &lt;/P&gt;
&lt;P class="xis-shortDescription"&gt;X would be the point of the cumulative you are specifically interested in which could be a variable or fixed value, your choice.&lt;/P&gt;
&lt;P class="xis-shortDescription"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class="xis-shortDescription"&gt;If that is not what you want then likely the Quantile function is what you want.&lt;/P&gt;
&lt;/DIV&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 20 Feb 2022 03:28:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-calculate-the-distribution-function-of-the-Gamma-a-b-law/m-p/797439#M287534</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-02-20T03:28:55Z</dc:date>
    </item>
    <item>
      <title>Re: how to calculate the distribution function of the Gamma(a,b) law then to calculate F(k), F(k-1),</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-calculate-the-distribution-function-of-the-Gamma-a-b-law/m-p/797444#M287538</link>
      <description>Thank you for that answer. I was not aware of this function (CDF).</description>
      <pubDate>Sun, 20 Feb 2022 06:12:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-calculate-the-distribution-function-of-the-Gamma-a-b-law/m-p/797444#M287538</guid>
      <dc:creator>Gick</dc:creator>
      <dc:date>2022-02-20T06:12:21Z</dc:date>
    </item>
    <item>
      <title>Re: how to calculate the distribution function of the Gamma(a,b) law then to calculate F(k), F(k-1),</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-calculate-the-distribution-function-of-the-Gamma-a-b-law/m-p/797453#M287546</link>
      <description>here is the calculation of the cumulative density function F(k) according to the Gamma distribution with parameter (a,b)&lt;BR /&gt;F_k=cdf('GAMMA', k, a, b);&lt;BR /&gt;&lt;BR /&gt;of F(k-1), we have&lt;BR /&gt;F_k1=cdf('GAMMA', k-1, a, b);&lt;BR /&gt;&lt;BR /&gt;Awaiting your comments</description>
      <pubDate>Sun, 20 Feb 2022 10:49:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-calculate-the-distribution-function-of-the-Gamma-a-b-law/m-p/797453#M287546</guid>
      <dc:creator>Gick</dc:creator>
      <dc:date>2022-02-20T10:49:04Z</dc:date>
    </item>
    <item>
      <title>Re: how to calculate the distribution function of the Gamma(a,b) law then to calculate F(k), F(k-1),</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-calculate-the-distribution-function-of-the-Gamma-a-b-law/m-p/797520#M313542</link>
      <description>&lt;P&gt;As long as your K has the appropriate value then that is likely the correct call.&lt;/P&gt;</description>
      <pubDate>Mon, 21 Feb 2022 02:09:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-calculate-the-distribution-function-of-the-Gamma-a-b-law/m-p/797520#M313542</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-02-21T02:09:18Z</dc:date>
    </item>
  </channel>
</rss>

