<?xml version="1.0" encoding="UTF-8"?>

<!--
 *
 * This help file was generated from distfun_hygernd.sci using help_from_sci().
 *
 -->

<refentry version="5.0-subset Scilab" xml:id="distfun_hygernd" xml:lang="en"
          xmlns="http://docbook.org/ns/docbook"
          xmlns:xlink="http://www.w3.org/1999/xlink"
          xmlns:svg="http://www.w3.org/2000/svg"
          xmlns:ns3="http://www.w3.org/1999/xhtml"
          xmlns:mml="http://www.w3.org/1998/Math/MathML"
          xmlns:scilab="http://www.scilab.org"
          xmlns:db="http://docbook.org/ns/docbook">

  <refnamediv>
    <refname>distfun_hygernd</refname>
    <refpurpose>Hypergeometric random numbers</refpurpose>
  </refnamediv>


<refsynopsisdiv>
   <title>Calling Sequence</title>
   <synopsis>
   x = distfun_hygernd(M,k,N)
   x = distfun_hygernd(M,k,N,[m,n])
   x = distfun_hygernd(M,k,N,m,n)
   
   </synopsis>
</refsynopsisdiv>

<refsection>
   <title>Parameters</title>
   <variablelist>
   <varlistentry><term>M :</term>
      <listitem><para> a matrix of doubles, the total size of the population . M belongs to the set {0,1,2,3........}</para></listitem></varlistentry>
   <varlistentry><term>k :</term>
      <listitem><para> a matrix of doubles, the number of successful states in the population . k belongs to the set {0,1,2,3.......M-1,M}</para></listitem></varlistentry>
   <varlistentry><term>N :</term>
      <listitem><para> a matrix of doubles, the total number of draws in the experiment . N belongs to the set {0,1,2,3,.......M-1,M}</para></listitem></varlistentry>
   <varlistentry><term>m :</term>
      <listitem><para> a 1-by-1 matrix of floating point integers, the number of rows of x</para></listitem></varlistentry>
   <varlistentry><term>n :</term>
      <listitem><para> a 1-by-1 matrix of floating point integers, the number of columns of x</para></listitem></varlistentry>
   <varlistentry><term>x:</term>
      <listitem><para> a matrix of doubles, the random numbers in the set {0,1,2,...,min(N,k)}.</para></listitem></varlistentry>
   </variablelist>
</refsection>

<refsection>
   <title>Description</title>
   <para>
Generates random variables from the Hypergeometric distribution function.
   </para>
   <para>
Any scalar input argument is expanded to a matrix of doubles
of the same size as the other input arguments.
   </para>
   <para>
The algorithm is based on the inversion of the CDF.
   </para>
   <para>
</para>
</refsection>

<refsection>
   <title>Examples</title>
   <programlisting role="example"><![CDATA[
// Check x = distfun_hygernd(M,k,N,v)
x = distfun_hygernd(80,50,30,[4 5])

// Check mean and variance
M = 80;
k = 50;
N = 30;
n = 50000;
x = distfun_hygernd(M,k,N,[1 n]);
Mx = mean(x)
Vx = variance(x)
[M,V] = distfun_hygestat(M,k,N)

// Check actual distribution
h=scf();
M=80;
k=50;
N=30;
nsamples=10000;
x=distfun_hygernd(M,k,N,1,nsamples);
distfun_inthisto(x);
h.children.children(1).children.background=-2;
[Me,Va] = distfun_hygestat(M,k,N);
x=int(Me-3*sqrt(Va)):int(Me+3*sqrt(Va));
y=distfun_hygepdf(x,M,k,N);
plot(x,y,"ro-");
xtitle("Hypergeometric Random Numbers","X","Frequency")
legend(["Empirical","PDF"]);

   ]]></programlisting>
</refsection>

<refsection>
   <title>Bibliography</title>
   <para>http://en.wikipedia.org/wiki/Hypergeometric_distribution</para>
</refsection>

<refsection>
   <title>Authors</title>
   <simplelist type="vert">
   <member>Copyright (C) 2012 - Prateek Papriwal</member>
   <member>Copyright (C) 2012 - 2014 - Michael Baudin</member>
   </simplelist>
</refsection>
</refentry>
