<?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 Re: how to calculate hypergeometric distribution in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/how-to-calculate-hypergeometric-distribution/m-p/821956#M34958</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Start here :&lt;/P&gt;
&lt;P&gt;SAS® 9.4 and SAS® Viya® 3.5 Programming Documentation | SAS 9.4 / Viya 3.5&lt;BR /&gt;Functions and CALL Routines&lt;BR /&gt;CDF Hypergeometric Distribution &lt;A href="https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lefunctionsref/p1x9o3ozc5ft8yn1kcn0p6yg4awc.htm" target="_blank"&gt;https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lefunctionsref/p1x9o3ozc5ft8yn1kcn0p6yg4awc.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Maybe you need the QUANTILE function.&lt;BR /&gt;The QUANTILE function returns the quantile from a distribution that you specify. &lt;BR /&gt;The QUANTILE function is the inverse of the CDF function.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Other functions that SAS has for this distribution (and MANY other distributions) :&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;LOGCDF Function&lt;/LI&gt;
&lt;LI&gt;LOGPDF Function&lt;/LI&gt;
&lt;LI&gt;LOGSDF Function&lt;/LI&gt;
&lt;LI&gt;PDF Hypergeometric Distribution Function&lt;/LI&gt;
&lt;LI&gt;QUANTILE Function&lt;/LI&gt;
&lt;LI&gt;SDF Function&lt;/LI&gt;
&lt;LI&gt;SQUANTILE Function&lt;BR /&gt;&lt;BR /&gt;&lt;/LI&gt;
&lt;/UL&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _NULL_;
   y=probhypr(10000,4000,20,9);
   put y= percent7.2;
run;

data _NULL_;
   y=cdf('HYPER', 9, 10000, 4000, 20);
   put y= percent7.2;
run;
/* end of program */&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Koen&lt;/P&gt;</description>
    <pubDate>Thu, 07 Jul 2022 01:02:05 GMT</pubDate>
    <dc:creator>sbxkoenk</dc:creator>
    <dc:date>2022-07-07T01:02:05Z</dc:date>
    <item>
      <title>how to calculate hypergeometric distribution</title>
      <link>https://communities.sas.com/t5/New-SAS-User/how-to-calculate-hypergeometric-distribution/m-p/821946#M34954</link>
      <description>&lt;P&gt;How do I write a SAS function to calculate the hypergeometric distribution of there being &lt;STRONG&gt;more than nine females&lt;/STRONG&gt;&amp;nbsp;surveyed from a &lt;STRONG&gt;sample of twenty?&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;In a large university,&amp;nbsp;&lt;/SPAN&gt;&lt;FONT color="red"&gt;40&lt;/FONT&gt;&lt;SPAN&gt;% of the students are female.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;If a random sample of twenty students is selected, what is the probability that the sample will contain &lt;STRONG&gt;more than nine female students?&lt;/STRONG&gt; (Round your answer to four decimal places.)&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE class="s-table" style="height: 649px; background-color: #e6f2fa; border-style: solid; border-color: #000000;"&gt;
&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH width="187px" height="38px"&gt;sample #of females surveyed:&lt;/TH&gt;
&lt;TH width="202.312px" height="38px"&gt;&amp;nbsp;&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="187px" height="30px"&gt;0&lt;/TD&gt;
&lt;TD width="202.312px" height="30px"&gt;3.6561584400629733e-05&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="187px" height="30px"&gt;1&lt;/TD&gt;
&lt;TD width="202.312px" height="30px"&gt;0.000487487792008398&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="187px" height="30px"&gt;2&lt;/TD&gt;
&lt;TD width="202.312px" height="30px"&gt;0.0030874226827198492&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="187px" height="30px"&gt;3&lt;/TD&gt;
&lt;TD width="202.312px" height="30px"&gt;0.012349690730879413&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="187px" height="30px"&gt;4&lt;/TD&gt;
&lt;TD width="202.312px" height="30px"&gt;0.034990790404158215&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="187px" height="30px"&gt;5&lt;/TD&gt;
&lt;TD width="202.312px" height="30px"&gt;0.0746470195288711&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="187px" height="30px"&gt;6&lt;/TD&gt;
&lt;TD width="202.312px" height="30px"&gt;0.12441169921478513&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="187px" height="30px"&gt;7&lt;/TD&gt;
&lt;TD width="202.312px" height="30px"&gt;0.1658822656197136&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="187px" height="30px"&gt;8&lt;/TD&gt;
&lt;TD width="202.312px" height="30px"&gt;0.17970578775468962&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="187px" height="30px"&gt;9&lt;/TD&gt;
&lt;TD width="202.312px" height="30px"&gt;0.1597384780041684&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="187px" height="30px"&gt;10&lt;/TD&gt;
&lt;TD width="202.312px" height="30px"&gt;0.11714155053639005&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="187px" height="30px"&gt;11&lt;/TD&gt;
&lt;TD width="202.312px" height="30px"&gt;0.07099487911296365&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="187px" height="30px"&gt;12&lt;/TD&gt;
&lt;TD width="202.312px" height="30px"&gt;0.03549743955648174&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="187px" height="30px"&gt;13&lt;/TD&gt;
&lt;TD width="202.312px" height="30px"&gt;0.01456305212573616&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="187px" height="30px"&gt;14&lt;/TD&gt;
&lt;TD width="202.312px" height="30px"&gt;0.004854350708578719&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="187px" height="30px"&gt;15&lt;/TD&gt;
&lt;TD width="202.312px" height="30px"&gt;0.0012944935222876583&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="187px" height="30px"&gt;16&lt;/TD&gt;
&lt;TD width="202.312px" height="30px"&gt;0.00026968615047659553&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="187px" height="30px"&gt;17&lt;/TD&gt;
&lt;TD width="202.312px" height="30px"&gt;4.2303709878681673e-05&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="187px" height="30px"&gt;18&lt;/TD&gt;
&lt;TD width="202.312px" height="30px"&gt;4.70041220874241e-06&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="187px" height="30px"&gt;19&lt;/TD&gt;
&lt;TD width="202.312px" height="30px"&gt;3.2985348833280015e-07&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="187px" height="30px"&gt;20&lt;/TD&gt;
&lt;TD width="202.312px" height="30px"&gt;1.0995116277760013e-08&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;I generated the table above using Python, so I imagine this data is likely inconsistent. However, it provided me with the correct probability for&amp;nbsp;&lt;EM&gt;exactly four females.&amp;nbsp;&lt;/EM&gt;which was&amp;nbsp;&lt;STRONG&gt;0.0350.&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am currently trying to write a function for the excerpt below:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;EM&gt;&amp;nbsp;&lt;/EM&gt;&lt;SPAN&gt;If a random sample of twenty students is selected, what is the probability that the sample will contain &lt;STRONG&gt;more than nine female students&lt;/STRONG&gt;?&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;</description>
      <pubDate>Wed, 06 Jul 2022 23:24:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/how-to-calculate-hypergeometric-distribution/m-p/821946#M34954</guid>
      <dc:creator>LABRADOR</dc:creator>
      <dc:date>2022-07-06T23:24:23Z</dc:date>
    </item>
    <item>
      <title>Re: how to calculate binomial probability with lower fence of 9</title>
      <link>https://communities.sas.com/t5/New-SAS-User/how-to-calculate-hypergeometric-distribution/m-p/821950#M34955</link>
      <description>Please clarify your column headings? How is this binomial?</description>
      <pubDate>Wed, 06 Jul 2022 22:49:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/how-to-calculate-hypergeometric-distribution/m-p/821950#M34955</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-07-06T22:49:27Z</dc:date>
    </item>
    <item>
      <title>Re: how to calculate binomial probability with lower fence of 9</title>
      <link>https://communities.sas.com/t5/New-SAS-User/how-to-calculate-hypergeometric-distribution/m-p/821953#M34956</link>
      <description>You sure it's hypergeometric? I think you were right initially at binomial...&lt;BR /&gt;</description>
      <pubDate>Wed, 06 Jul 2022 23:51:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/how-to-calculate-hypergeometric-distribution/m-p/821953#M34956</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-07-06T23:51:32Z</dc:date>
    </item>
    <item>
      <title>Re: how to calculate hypergeometric distribution</title>
      <link>https://communities.sas.com/t5/New-SAS-User/how-to-calculate-hypergeometric-distribution/m-p/821956#M34958</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Start here :&lt;/P&gt;
&lt;P&gt;SAS® 9.4 and SAS® Viya® 3.5 Programming Documentation | SAS 9.4 / Viya 3.5&lt;BR /&gt;Functions and CALL Routines&lt;BR /&gt;CDF Hypergeometric Distribution &lt;A href="https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lefunctionsref/p1x9o3ozc5ft8yn1kcn0p6yg4awc.htm" target="_blank"&gt;https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lefunctionsref/p1x9o3ozc5ft8yn1kcn0p6yg4awc.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Maybe you need the QUANTILE function.&lt;BR /&gt;The QUANTILE function returns the quantile from a distribution that you specify. &lt;BR /&gt;The QUANTILE function is the inverse of the CDF function.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Other functions that SAS has for this distribution (and MANY other distributions) :&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;LOGCDF Function&lt;/LI&gt;
&lt;LI&gt;LOGPDF Function&lt;/LI&gt;
&lt;LI&gt;LOGSDF Function&lt;/LI&gt;
&lt;LI&gt;PDF Hypergeometric Distribution Function&lt;/LI&gt;
&lt;LI&gt;QUANTILE Function&lt;/LI&gt;
&lt;LI&gt;SDF Function&lt;/LI&gt;
&lt;LI&gt;SQUANTILE Function&lt;BR /&gt;&lt;BR /&gt;&lt;/LI&gt;
&lt;/UL&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _NULL_;
   y=probhypr(10000,4000,20,9);
   put y= percent7.2;
run;

data _NULL_;
   y=cdf('HYPER', 9, 10000, 4000, 20);
   put y= percent7.2;
run;
/* end of program */&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Koen&lt;/P&gt;</description>
      <pubDate>Thu, 07 Jul 2022 01:02:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/how-to-calculate-hypergeometric-distribution/m-p/821956#M34958</guid>
      <dc:creator>sbxkoenk</dc:creator>
      <dc:date>2022-07-07T01:02:05Z</dc:date>
    </item>
    <item>
      <title>Re: how to calculate hypergeometric distribution</title>
      <link>https://communities.sas.com/t5/New-SAS-User/how-to-calculate-hypergeometric-distribution/m-p/822040#M34961</link>
      <description>You missed a very important parameter: the number of students in the large university .&lt;BR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13684"&gt;@Rick_SAS&lt;/a&gt; wrote many blogs about this topic .&lt;BR /&gt;&lt;A href="https://blogs.sas.com/content/iml/2015/09/30/balls-and-urns1.html" target="_blank"&gt;https://blogs.sas.com/content/iml/2015/09/30/balls-and-urns1.html&lt;/A&gt;&lt;BR /&gt;&lt;A href="https://blogs.sas.com/content/iml/2015/10/21/simulate-contingency-tables-fixed-sums-sas.html" target="_blank"&gt;https://blogs.sas.com/content/iml/2015/10/21/simulate-contingency-tables-fixed-sums-sas.html&lt;/A&gt;&lt;BR /&gt;&lt;A href="https://blogs.sas.com/content/iml/2015/10/02/balls-and-urns2.html" target="_blank"&gt;https://blogs.sas.com/content/iml/2015/10/02/balls-and-urns2.html&lt;/A&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 07 Jul 2022 11:49:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/how-to-calculate-hypergeometric-distribution/m-p/822040#M34961</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2022-07-07T11:49:33Z</dc:date>
    </item>
    <item>
      <title>Re: how to calculate hypergeometric distribution</title>
      <link>https://communities.sas.com/t5/New-SAS-User/how-to-calculate-hypergeometric-distribution/m-p/822050#M34962</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt; &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/60547"&gt;@sbxkoenk&lt;/a&gt; &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;Thanks to all of you. I greatly appreciate the help.&lt;/P&gt;</description>
      <pubDate>Thu, 07 Jul 2022 13:24:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/how-to-calculate-hypergeometric-distribution/m-p/822050#M34962</guid>
      <dc:creator>LABRADOR</dc:creator>
      <dc:date>2022-07-07T13:24:50Z</dc:date>
    </item>
    <item>
      <title>Re: how to calculate hypergeometric distribution</title>
      <link>https://communities.sas.com/t5/New-SAS-User/how-to-calculate-hypergeometric-distribution/m-p/822053#M34963</link>
      <description>&lt;P&gt;Clearly, this is an assignment, so let me provide some hints rather than the solution:&lt;/P&gt;
&lt;P&gt;1. The hypergeometric distribution is used when you want the probabilities for a small finite population where the size of the population is known. Assuming that the university is large, I suspect the instructor intends you to use a binomial distribution. To use the hypergeometric distribution, you must know the total number of students at the university and the number of females. For large populations (like 500 or more students), the hypergeometric and the binomial distributions are similar.&lt;/P&gt;
&lt;P&gt;2. There are two related concepts here. If you want to know the probability that EXACTLY k females appear in a sample of size 20, you can use the PDF for the binomial distribution:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* prob of exactly 4 females in a sample of size 20 */
p4 = pdf("Binomial", 
         4,        /* Prob that sample contains &amp;lt;= 9 females */
         0.4,      /* Population has 40% female */
         20);      /* sample size */
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This appears to be what you did in Python.&amp;nbsp; If you want to know the probability that there will be 4 OR LESS females in the sample, you use the CDF function:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* prob of 4 or less females in a sample of size 20 */
pLE4 = cdf("Binomial", 
         4,        /* Prob that sample contains &amp;lt;= 9 females */
         0.4,      /* Population has 40% female */
         20);      /* sample size */
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;3. Use the example above to compute the probability that &lt;STRONG&gt;9 or fewer&lt;/STRONG&gt; females are in the sample.&lt;/P&gt;
&lt;P&gt;4. The problem asked for the probability of&amp;nbsp;&lt;STRONG&gt;more than 9&lt;/STRONG&gt; females. How do you get that probability from the answer in 3? (Hint: maybe use subtraction....)&lt;/P&gt;</description>
      <pubDate>Thu, 07 Jul 2022 13:29:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/how-to-calculate-hypergeometric-distribution/m-p/822053#M34963</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2022-07-07T13:29:54Z</dc:date>
    </item>
    <item>
      <title>Re: how to calculate hypergeometric distribution</title>
      <link>https://communities.sas.com/t5/New-SAS-User/how-to-calculate-hypergeometric-distribution/m-p/822057#M34964</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13684"&gt;@Rick_SAS&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Thu, 07 Jul 2022 13:43:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/how-to-calculate-hypergeometric-distribution/m-p/822057#M34964</guid>
      <dc:creator>LABRADOR</dc:creator>
      <dc:date>2022-07-07T13:43:20Z</dc:date>
    </item>
  </channel>
</rss>

