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

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

<refentry version="5.0-subset Scilab" xml:id="distfun_mnstat" 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_mnstat</refname>
    <refpurpose>Multinomial mean and covariance</refpurpose>
  </refnamediv>


<refsynopsisdiv>
   <title>Calling Sequence</title>
   <synopsis>
   M = distfun_mnstat(n,P)
   [M,C] = distfun_mnstat(n,P)
   
   </synopsis>
</refsynopsisdiv>

<refsection>
   <title>Parameters</title>
   <variablelist>
   <varlistentry><term>n :</term>
      <listitem><para> a 1-by-1 matrix of doubles, integer value, positive, the number of trials</para></listitem></varlistentry>
   <varlistentry><term>P :</term>
      <listitem><para> a 1-by-k matrix of doubles, positive, sum to 1, the probability of the k categories</para></listitem></varlistentry>
   <varlistentry><term>M :</term>
      <listitem><para> a 1-by-1 matrix of doubles, the mean</para></listitem></varlistentry>
   <varlistentry><term>C :</term>
      <listitem><para> a k-by-k matrix of doubles, the variance-covariance matrix</para></listitem></varlistentry>
   </variablelist>
</refsection>

<refsection>
   <title>Description</title>
   <para>
Computes statistics from the multinomial distribution.
On input, we assume that sum(P)==1.
   </para>
   <para>
The Mean and Covariance matrix of the Multinomial Distribution is:
   </para>
   <para>
<latex>
\begin{eqnarray}
M &amp;=&amp; n P \\
C_{i,i} &amp;=&amp; n p_i (1-p_i) \\
C_{i,j} &amp;=&amp; - n p_i p_j, \quad \textrm{i\neq j}
\end{eqnarray}
</latex>
   </para>
   <para>
</para>
</refsection>

<refsection>
   <title>Examples</title>
   <programlisting role="example"><![CDATA[
n = 10
P = [0.3 0.4 0.3]
[M,C] = distfun_mnstat(n,P)
Mexpected = [3 4 3]
Cexpected = [
2.1  -1.2  -0.9
-1.2   2.4  -1.2
-0.9  -1.2   2.1
]

   ]]></programlisting>
</refsection>

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

<refsection>
   <title>Bibliography</title>
   <para>Wikipedia, Multinomial distribution function, http://en.wikipedia.org/wiki/Multinomial_distribution</para>
</refsection>
</refentry>
