<?xml version='1.0' encoding='UTF-8' standalone='no'?>
<doxygen xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="compound.xsd" version="1.5.6">
  <compounddef id="libEF_8cpp" kind="file">
    <compoundname>libEF.cpp</compoundname>
    <includes local="no">itpp/itbase.h</includes>
    <includes local="no">itpp/base/bessel.h</includes>
    <includes refid="libEF_8h" local="yes">libEF.h</includes>
    <includes local="no">math.h</includes>
    <incdepgraph>
      <node id="382">
        <label>work/git/mixpp/bdm/stat/libEF.cpp</label>
        <link refid="libEF.cpp"/>
        <childnode refid="383" relation="include">
        </childnode>
        <childnode refid="384" relation="include">
        </childnode>
        <childnode refid="385" relation="include">
        </childnode>
        <childnode refid="389" relation="include">
        </childnode>
      </node>
      <node id="387">
        <label>libBM.h</label>
        <link refid="libBM_8h"/>
        <childnode refid="383" relation="include">
        </childnode>
      </node>
      <node id="388">
        <label>../itpp_ext.h</label>
        <link refid="itpp__ext_8h-source"/>
        <childnode refid="383" relation="include">
        </childnode>
      </node>
      <node id="385">
        <label>libEF.h</label>
        <link refid="libEF_8h"/>
        <childnode refid="383" relation="include">
        </childnode>
        <childnode refid="386" relation="include">
        </childnode>
        <childnode refid="387" relation="include">
        </childnode>
        <childnode refid="388" relation="include">
        </childnode>
      </node>
      <node id="384">
        <label>itpp/base/bessel.h</label>
      </node>
      <node id="389">
        <label>math.h</label>
      </node>
      <node id="383">
        <label>itpp/itbase.h</label>
      </node>
      <node id="386">
        <label>../math/libDC.h</label>
        <link refid="libDC_8h"/>
        <childnode refid="383" relation="include">
        </childnode>
      </node>
    </incdepgraph>
      <sectiondef kind="var">
      <memberdef kind="variable" id="libEF_8cpp_12ae7dcdfebede774dd1b1f16cad10dd9" prot="public" static="no" mutable="no">
        <type>Uniform_RNG</type>
        <definition>Uniform_RNG UniRNG</definition>
        <argsstring></argsstring>
        <name>UniRNG</name>
        <briefdescription>
<para>Global Uniform_RNG. </para>        </briefdescription>
        <detaileddescription>
        </detaileddescription>
        <inbodydescription>
        </inbodydescription>
        <location file="/home/smidl/work/git/mixpp/bdm/stat/libEF.cpp" line="8" bodyfile="/home/smidl/work/git/mixpp/bdm/stat/libEF.cpp" bodystart="8" bodyend="-1"/>
      </memberdef>
      <memberdef kind="variable" id="libEF_8cpp_1395c5925c8792aef3be4c360e91526c0" prot="public" static="no" mutable="no">
        <type>Normal_RNG</type>
        <definition>Normal_RNG NorRNG</definition>
        <argsstring></argsstring>
        <name>NorRNG</name>
        <briefdescription>
<para>Global Normal_RNG. </para>        </briefdescription>
        <detaileddescription>
        </detaileddescription>
        <inbodydescription>
        </inbodydescription>
        <location file="/home/smidl/work/git/mixpp/bdm/stat/libEF.cpp" line="9" bodyfile="/home/smidl/work/git/mixpp/bdm/stat/libEF.cpp" bodystart="9" bodyend="-1"/>
      </memberdef>
      <memberdef kind="variable" id="libEF_8cpp_1884a8348c92a49725b78e2b6ab0bb802" prot="public" static="no" mutable="no">
        <type><ref refid="classitpp_1_1Gamma__RNG" kindref="compound">Gamma_RNG</ref></type>
        <definition>Gamma_RNG GamRNG</definition>
        <argsstring></argsstring>
        <name>GamRNG</name>
        <briefdescription>
<para>Global Gamma_RNG. </para>        </briefdescription>
        <detaileddescription>
        </detaileddescription>
        <inbodydescription>
        </inbodydescription>
        <location file="/home/smidl/work/git/mixpp/bdm/stat/libEF.cpp" line="10" bodyfile="/home/smidl/work/git/mixpp/bdm/stat/libEF.cpp" bodystart="10" bodyend="-1"/>
      </memberdef>
      </sectiondef>
    <briefdescription>
    </briefdescription>
    <detaileddescription>
    </detaileddescription>
    <programlisting>
<codeline lineno="1"><highlight class="preprocessor">#include<sp/>&lt;itpp/itbase.h&gt;</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="2"><highlight class="normal"></highlight><highlight class="preprocessor">#include<sp/>&lt;itpp/base/bessel.h&gt;</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="3"><highlight class="normal"></highlight><highlight class="preprocessor">#include<sp/>&quot;<ref refid="libEF_8h" kindref="compound" tooltip="Probability distributions for Exponential Family models.">libEF.h</ref>&quot;</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="4"><highlight class="normal"></highlight><highlight class="preprocessor">#include<sp/>&lt;math.h&gt;</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="5"><highlight class="normal"></highlight></codeline>
<codeline lineno="6"><highlight class="normal"></highlight><highlight class="keyword">using<sp/>namespace<sp/></highlight><highlight class="normal">itpp;</highlight></codeline>
<codeline lineno="7"><highlight class="normal"></highlight></codeline>
<codeline lineno="8" refid="libEF_8h_12ae7dcdfebede774dd1b1f16cad10dd9" refkind="member"><highlight class="normal">Uniform_RNG<sp/>UniRNG;</highlight></codeline>
<codeline lineno="9" refid="libEF_8h_1395c5925c8792aef3be4c360e91526c0" refkind="member"><highlight class="normal">Normal_RNG<sp/>NorRNG;</highlight></codeline>
<codeline lineno="10" refid="libEF_8h_1884a8348c92a49725b78e2b6ab0bb802" refkind="member"><highlight class="normal"><ref refid="classitpp_1_1Gamma__RNG" kindref="compound" tooltip="Gamma distribution.">Gamma_RNG</ref><sp/>GamRNG;</highlight></codeline>
<codeline lineno="11"><highlight class="normal"></highlight></codeline>
<codeline lineno="12"><highlight class="normal"></highlight><highlight class="keyword">using</highlight><highlight class="normal"><sp/>std::cout;</highlight></codeline>
<codeline lineno="13"><highlight class="normal"></highlight></codeline>
<codeline lineno="14" refid="classegiw_13d2c1f2ba0f9966781f1e0ae695e8a6f" refkind="member"><highlight class="normal">vec<sp/><ref refid="classegiw_13d2c1f2ba0f9966781f1e0ae695e8a6f" kindref="member" tooltip="Returns the required moment of the epdf.">egiw::sample</ref>()</highlight><highlight class="keyword"><sp/>const<sp/></highlight><highlight class="normal">{</highlight></codeline>
<codeline lineno="15"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>it_warning(</highlight><highlight class="stringliteral">&quot;Function<sp/>not<sp/>implemented&quot;</highlight><highlight class="normal">);</highlight></codeline>
<codeline lineno="16"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>vec_1(0.0);</highlight></codeline>
<codeline lineno="17"><highlight class="normal">}</highlight></codeline>
<codeline lineno="18"><highlight class="normal"></highlight></codeline>
<codeline lineno="19" refid="classegiw_1425cbc53b377274e28c6add942bab62d" refkind="member"><highlight class="normal"></highlight><highlight class="keywordtype">double</highlight><highlight class="normal"><sp/><ref refid="classegiw_1425cbc53b377274e28c6add942bab62d" kindref="member" tooltip="Compute log-probability of argument val.">egiw::evalpdflog</ref>(<sp/></highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/>vec<sp/>&amp;val<sp/>)</highlight><highlight class="keyword"><sp/>const<sp/></highlight><highlight class="normal">{</highlight></codeline>
<codeline lineno="20"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>nPsi<sp/>=<sp/><ref refid="classepdf_174da992e3f5d598da8850b646b79b9d9" kindref="member" tooltip="Identified of the random variable.">rv</ref>.<ref refid="classRV_1f5c7b8bd589eef09ccdf3329a0addea0" kindref="member" tooltip="Return number of scalars in the RV.">count</ref>()-1;<sp/></highlight><highlight class="comment">//<sp/>assuming<sp/>1dim<sp/>y</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="21"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordtype">double</highlight><highlight class="normal"><sp/>k<sp/>=<sp/><ref refid="classegiw_14a2f130b91afe84f6d62fed289d5d453" kindref="member" tooltip="Number of data records (degrees of freedom) of sufficient statistics.">nu</ref><sp/>+<sp/>nPsi<sp/>+<sp/>2;</highlight></codeline>
<codeline lineno="22"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight></codeline>
<codeline lineno="23"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordtype">double</highlight><highlight class="normal"><sp/>r<sp/>=<sp/>val(nPsi);<sp/></highlight><highlight class="comment">//last<sp/>entry!</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="24"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>vec<sp/>Psi(nPsi+1);</highlight></codeline>
<codeline lineno="25"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>Psi(0)<sp/>=<sp/>-1.0;</highlight></codeline>
<codeline lineno="26"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>Psi.set_subvector(1,val);<sp/></highlight><highlight class="comment">//<sp/>fill<sp/>the<sp/>rest</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="27"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight></codeline>
<codeline lineno="28"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>-0.5*(<sp/>k*log(r)<sp/>+<sp/><ref refid="classegiw_1f343d03ede89db820edf44a6297fa442" kindref="member" tooltip="Extended information matrix of sufficient statistics.">V</ref>.<ref refid="classldmat_1d64f331b781903e913cb2ee836886f3f" kindref="member" tooltip="Evaluates quadratic form ;.">qform</ref>(Psi))<sp/>-<sp/><ref refid="classegiw_170eb1a0b88459b227f919b425b0d3359" kindref="member" tooltip="logarithm of the normalizing constant, ">lognc</ref>();</highlight></codeline>
<codeline lineno="29"><highlight class="normal">}</highlight></codeline>
<codeline lineno="30"><highlight class="normal"></highlight></codeline>
<codeline lineno="31" refid="classegiw_170eb1a0b88459b227f919b425b0d3359" refkind="member"><highlight class="normal"></highlight><highlight class="keywordtype">double</highlight><highlight class="normal"><sp/><ref refid="classegiw_170eb1a0b88459b227f919b425b0d3359" kindref="member" tooltip="logarithm of the normalizing constant, ">egiw::lognc</ref>()</highlight><highlight class="keyword"><sp/>const</highlight><highlight class="normal">{</highlight></codeline>
<codeline lineno="32"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/>vec&amp;<sp/>D<sp/>=<sp/><ref refid="classegiw_1f343d03ede89db820edf44a6297fa442" kindref="member" tooltip="Extended information matrix of sufficient statistics.">V</ref>.<ref refid="classldmat_1282c879f50aa9ef934e7f46d86881582" kindref="member" tooltip="Access functions.">_D</ref>();</highlight></codeline>
<codeline lineno="33"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>nPsi<sp/>=<sp/>D.length()-1;<sp/></highlight><highlight class="comment">//<sp/>assuming<sp/>1dim<sp/>y</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="34"><highlight class="normal"></highlight></codeline>
<codeline lineno="35"><highlight class="normal"></highlight><highlight class="comment">//<sp/>log(2)<sp/>=<sp/>0.693147180559945286226763983</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="36"><highlight class="normal"></highlight><highlight class="comment">//<sp/>log(pi)<sp/>=<sp/>1.144729885849400163877476189</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="37"><highlight class="normal"></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>lgamma(0.5*<ref refid="classegiw_14a2f130b91afe84f6d62fed289d5d453" kindref="member" tooltip="Number of data records (degrees of freedom) of sufficient statistics.">nu</ref>)<sp/>+<sp/>0.5*((1.0-<ref refid="classegiw_14a2f130b91afe84f6d62fed289d5d453" kindref="member" tooltip="Number of data records (degrees of freedom) of sufficient statistics.">nu</ref>)*log(D(0))<sp/>-<sp/><ref refid="classegiw_1f343d03ede89db820edf44a6297fa442" kindref="member" tooltip="Extended information matrix of sufficient statistics.">V</ref>.<ref refid="classldmat_12b42750ba4962d439aa52a77ae12949b" kindref="member" tooltip="Logarithm of a determinant.">logdet</ref>()<sp/>+<sp/>(<ref refid="classegiw_14a2f130b91afe84f6d62fed289d5d453" kindref="member" tooltip="Number of data records (degrees of freedom) of sufficient statistics.">nu</ref>+nPsi)*0.693147180559945286226763983<sp/>+<sp/>nPsi*1.144729885849400163877476189);</highlight></codeline>
<codeline lineno="38"><highlight class="normal">}</highlight></codeline>
<codeline lineno="39"><highlight class="normal"></highlight></codeline>
<codeline lineno="40" refid="classegiw_16deb0ff2859f41ef7cbdf6a842cabb29" refkind="member"><highlight class="normal">vec<sp/><ref refid="classegiw_16deb0ff2859f41ef7cbdf6a842cabb29" kindref="member" tooltip="return expected value">egiw::mean</ref>()</highlight><highlight class="keyword"><sp/>const<sp/></highlight><highlight class="normal">{</highlight></codeline>
<codeline lineno="41"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/>mat<sp/>&amp;L=<sp/><ref refid="classegiw_1f343d03ede89db820edf44a6297fa442" kindref="member" tooltip="Extended information matrix of sufficient statistics.">V</ref>.<ref refid="classldmat_15f44f100248c6627314afaa653b9e5bd" kindref="member" tooltip="Access functions.">_L</ref>();</highlight></codeline>
<codeline lineno="42"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/>vec<sp/>&amp;D=<sp/><ref refid="classegiw_1f343d03ede89db820edf44a6297fa442" kindref="member" tooltip="Extended information matrix of sufficient statistics.">V</ref>.<ref refid="classldmat_1282c879f50aa9ef934e7f46d86881582" kindref="member" tooltip="Access functions.">_D</ref>();</highlight></codeline>
<codeline lineno="43"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight></codeline>
<codeline lineno="44"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>end<sp/>=<sp/>L.rows()-1;</highlight></codeline>
<codeline lineno="45"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>vec<sp/>L0<sp/>=<sp/>L.get_col(0);</highlight></codeline>
<codeline lineno="46"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight></codeline>
<codeline lineno="47"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>vec<sp/>m(D.length());</highlight></codeline>
<codeline lineno="48"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>mat<sp/>iLsub<sp/>=<sp/>ltuinv(L(1,end,1,end));</highlight></codeline>
<codeline lineno="49"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>m.set_subvector(0,iLsub*L0(1,end));</highlight></codeline>
<codeline lineno="50"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>m(end)=<sp/>D(0)/(<ref refid="classegiw_14a2f130b91afe84f6d62fed289d5d453" kindref="member" tooltip="Number of data records (degrees of freedom) of sufficient statistics.">nu</ref>-2.0);</highlight></codeline>
<codeline lineno="51"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight></codeline>
<codeline lineno="52"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>m;</highlight></codeline>
<codeline lineno="53"><highlight class="normal">}</highlight></codeline>
<codeline lineno="54"><highlight class="normal"></highlight></codeline>
<codeline lineno="55" refid="classegamma_18e10c0021b5dfdd9cb62c6959b5ef425" refkind="member"><highlight class="normal">vec<sp/><ref refid="classegamma_18e10c0021b5dfdd9cb62c6959b5ef425" kindref="member" tooltip="Returns the required moment of the epdf.">egamma::sample</ref>()</highlight><highlight class="keyword"><sp/>const<sp/></highlight><highlight class="normal">{</highlight></codeline>
<codeline lineno="56"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>vec<sp/>smp<sp/>(<sp/><ref refid="classepdf_174da992e3f5d598da8850b646b79b9d9" kindref="member" tooltip="Identified of the random variable.">rv</ref>.<ref refid="classRV_1f5c7b8bd589eef09ccdf3329a0addea0" kindref="member" tooltip="Return number of scalars in the RV.">count</ref>()<sp/>);</highlight></codeline>
<codeline lineno="57"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>i;</highlight></codeline>
<codeline lineno="58"><highlight class="normal"></highlight></codeline>
<codeline lineno="59"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">for</highlight><highlight class="normal"><sp/>(<sp/>i=0;<sp/>i&lt;<ref refid="classepdf_174da992e3f5d598da8850b646b79b9d9" kindref="member" tooltip="Identified of the random variable.">rv</ref>.<ref refid="classRV_1f5c7b8bd589eef09ccdf3329a0addea0" kindref="member" tooltip="Return number of scalars in the RV.">count</ref>();<sp/>i++<sp/>)<sp/>{</highlight></codeline>
<codeline lineno="60"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>GamRNG.<ref refid="classitpp_1_1Gamma__RNG_1dfaae19411e39aa87e1f72e409b6babe" kindref="member" tooltip="Set lambda.">setup</ref><sp/>(<sp/><ref refid="classegamma_1376cebd8932546c440f21b182910b01b" kindref="member" tooltip="Vector .">alpha</ref><sp/>(<sp/>i<sp/>),<ref refid="classegamma_1cfc5f136467488a421ab22f886323790" kindref="member" tooltip="Vector .">beta</ref><sp/>(<sp/>i<sp/>)<sp/>);</highlight></codeline>
<codeline lineno="61"><highlight class="normal"></highlight><highlight class="preprocessor"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>#pragma<sp/>omp<sp/>critical</highlight></codeline>
<codeline lineno="62"><highlight class="preprocessor"></highlight><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>smp<sp/>(<sp/>i<sp/>)<sp/>=<sp/>GamRNG();</highlight></codeline>
<codeline lineno="63"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="64"><highlight class="normal"></highlight></codeline>
<codeline lineno="65"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>smp;</highlight></codeline>
<codeline lineno="66"><highlight class="normal">}</highlight></codeline>
<codeline lineno="67"><highlight class="normal"></highlight></codeline>
<codeline lineno="68"><highlight class="normal"></highlight><highlight class="comment">//<sp/>mat<sp/>egamma::sample<sp/>(<sp/>int<sp/>N<sp/>)<sp/>const<sp/>{</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="69"><highlight class="normal"></highlight><highlight class="comment">//<sp/><sp/><sp/><sp/><sp/><sp/>mat<sp/>Smp<sp/>(<sp/>rv.count(),N<sp/>);</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="70"><highlight class="normal"></highlight><highlight class="comment">//<sp/><sp/><sp/><sp/><sp/><sp/>int<sp/>i,j;</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="71"><highlight class="normal"></highlight><highlight class="comment">//<sp/></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="72"><highlight class="normal"></highlight><highlight class="comment">//<sp/><sp/><sp/><sp/><sp/><sp/>for<sp/>(<sp/>i=0;<sp/>i&lt;rv.count();<sp/>i++<sp/>)<sp/>{</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="73"><highlight class="normal"></highlight><highlight class="comment">//<sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>GamRNG.setup<sp/>(<sp/>alpha<sp/>(<sp/>i<sp/>),beta<sp/>(<sp/>i<sp/>)<sp/>);</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="74"><highlight class="normal"></highlight><highlight class="comment">//<sp/></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="75"><highlight class="normal"></highlight><highlight class="comment">//<sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>for<sp/>(<sp/>j=0;<sp/>j&lt;N;<sp/>j++<sp/>)<sp/>{</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="76"><highlight class="normal"></highlight><highlight class="comment">//<sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>Smp<sp/>(<sp/>i,j<sp/>)<sp/>=<sp/>GamRNG();</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="77"><highlight class="normal"></highlight><highlight class="comment">//<sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="78"><highlight class="normal"></highlight><highlight class="comment">//<sp/><sp/><sp/><sp/><sp/><sp/>}</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="79"><highlight class="normal"></highlight><highlight class="comment">//<sp/></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="80"><highlight class="normal"></highlight><highlight class="comment">//<sp/><sp/><sp/><sp/><sp/><sp/>return<sp/>Smp;</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="81"><highlight class="normal"></highlight><highlight class="comment">//<sp/>}</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="82"><highlight class="normal"></highlight></codeline>
<codeline lineno="83" refid="classegamma_1de84faac8f9799dfe2777ddbedf997ef" refkind="member"><highlight class="normal"></highlight><highlight class="keywordtype">double</highlight><highlight class="normal"><sp/><ref refid="classegamma_1de84faac8f9799dfe2777ddbedf997ef" kindref="member" tooltip="TODO: is it used anywhere?">egamma::evalpdflog</ref><sp/>(<sp/></highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/>vec<sp/>&amp;val<sp/>)</highlight><highlight class="keyword"><sp/>const<sp/></highlight><highlight class="normal">{</highlight></codeline>
<codeline lineno="84"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordtype">double</highlight><highlight class="normal"><sp/>res<sp/>=<sp/>0.0;<sp/></highlight><highlight class="comment">//the<sp/>rest<sp/>will<sp/>be<sp/>added</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="85"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>i;</highlight></codeline>
<codeline lineno="86"><highlight class="normal"></highlight></codeline>
<codeline lineno="87"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">for</highlight><highlight class="normal"><sp/>(<sp/>i=0;<sp/>i&lt;<ref refid="classepdf_174da992e3f5d598da8850b646b79b9d9" kindref="member" tooltip="Identified of the random variable.">rv</ref>.<ref refid="classRV_1f5c7b8bd589eef09ccdf3329a0addea0" kindref="member" tooltip="Return number of scalars in the RV.">count</ref>();<sp/>i++<sp/>)<sp/>{</highlight></codeline>
<codeline lineno="88"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>res<sp/>+=<sp/>(<sp/><ref refid="classegamma_1376cebd8932546c440f21b182910b01b" kindref="member" tooltip="Vector .">alpha</ref><sp/>(<sp/>i<sp/>)<sp/>-<sp/>1<sp/>)<sp/>*std::log<sp/>(<sp/>val<sp/>(<sp/>i<sp/>)<sp/>)<sp/>-<sp/><ref refid="classegamma_1cfc5f136467488a421ab22f886323790" kindref="member" tooltip="Vector .">beta</ref><sp/>(<sp/>i<sp/>)<sp/>*val<sp/>(<sp/>i<sp/>);</highlight></codeline>
<codeline lineno="89"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="90"><highlight class="normal"></highlight></codeline>
<codeline lineno="91"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>res-<ref refid="classegamma_1d6dbbdb72360f9e54d64501f80318bb6" kindref="member" tooltip="logarithm of the normalizing constant, ">lognc</ref>();</highlight></codeline>
<codeline lineno="92"><highlight class="normal">}</highlight></codeline>
<codeline lineno="93"><highlight class="normal"></highlight></codeline>
<codeline lineno="94" refid="classegamma_1d6dbbdb72360f9e54d64501f80318bb6" refkind="member"><highlight class="normal"></highlight><highlight class="keywordtype">double</highlight><highlight class="normal"><sp/><ref refid="classegamma_1d6dbbdb72360f9e54d64501f80318bb6" kindref="member" tooltip="logarithm of the normalizing constant, ">egamma::lognc</ref>()</highlight><highlight class="keyword"><sp/>const<sp/></highlight><highlight class="normal">{</highlight></codeline>
<codeline lineno="95"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordtype">double</highlight><highlight class="normal"><sp/>res<sp/>=<sp/>0.0;<sp/></highlight><highlight class="comment">//will<sp/>be<sp/>added</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="96"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>i;</highlight></codeline>
<codeline lineno="97"><highlight class="normal"></highlight></codeline>
<codeline lineno="98"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">for</highlight><highlight class="normal"><sp/>(<sp/>i=0;<sp/>i&lt;<ref refid="classepdf_174da992e3f5d598da8850b646b79b9d9" kindref="member" tooltip="Identified of the random variable.">rv</ref>.<ref refid="classRV_1f5c7b8bd589eef09ccdf3329a0addea0" kindref="member" tooltip="Return number of scalars in the RV.">count</ref>();<sp/>i++<sp/>)<sp/>{</highlight></codeline>
<codeline lineno="99"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>res<sp/>+=<sp/>lgamma<sp/>(<sp/><ref refid="classegamma_1376cebd8932546c440f21b182910b01b" kindref="member" tooltip="Vector .">alpha</ref><sp/>(<sp/>i<sp/>)<sp/>)<sp/>-<sp/><ref refid="classegamma_1376cebd8932546c440f21b182910b01b" kindref="member" tooltip="Vector .">alpha</ref><sp/>(<sp/>i<sp/>)<sp/>*std::log<sp/>(<sp/><ref refid="classegamma_1cfc5f136467488a421ab22f886323790" kindref="member" tooltip="Vector .">beta</ref><sp/>(<sp/>i<sp/>)<sp/>)<sp/>;</highlight></codeline>
<codeline lineno="100"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="101"><highlight class="normal"></highlight></codeline>
<codeline lineno="102"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>res;</highlight></codeline>
<codeline lineno="103"><highlight class="normal">}</highlight></codeline>
<codeline lineno="104"><highlight class="normal"></highlight></codeline>
<codeline lineno="105"><highlight class="normal"></highlight><highlight class="comment">//MGamma</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="106" refid="classmgamma_1af43e61b86900c0398d5c0ffc83b94e6" refkind="member"><highlight class="normal"><ref refid="classmgamma_1af43e61b86900c0398d5c0ffc83b94e6" kindref="member" tooltip="Constructor.">mgamma::mgamma</ref><sp/>(<sp/></highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/><ref refid="classRV" kindref="compound" tooltip="Class representing variables, most often random variables.">RV</ref><sp/>&amp;<ref refid="classepdf_174da992e3f5d598da8850b646b79b9d9" kindref="member" tooltip="Identified of the random variable.">rv</ref>,</highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/><ref refid="classRV" kindref="compound" tooltip="Class representing variables, most often random variables.">RV</ref><sp/>&amp;rvc<sp/>)<sp/>:<sp/><ref refid="classmEF" kindref="compound" tooltip="Exponential family model.">mEF</ref><sp/>(<sp/>rv,rvc<sp/>),<sp/><ref refid="classepdf" kindref="compound" tooltip="Probability density function with numerical statistics, e.g. posterior density.">epdf</ref><sp/>(<sp/>rv<sp/>)<sp/>{vec*<sp/>tmp;<sp/><ref refid="classepdf" kindref="compound" tooltip="Probability density function with numerical statistics, e.g. posterior density.">epdf</ref>._param<sp/>(<sp/>tmp,<ref refid="classmgamma_15e90652837448bcc29707e7412f99691" kindref="member" tooltip="cache of epdf.beta">_beta</ref><sp/>);};</highlight></codeline>
<codeline lineno="107"><highlight class="normal"></highlight></codeline>
<codeline lineno="108" refid="classmgamma_1a9d646cf758a70126dde7c48790b6e94" refkind="member"><highlight class="normal"></highlight><highlight class="keywordtype">void</highlight><highlight class="normal"><sp/><ref refid="classmgamma_1a9d646cf758a70126dde7c48790b6e94" kindref="member" tooltip="Set value of k.">mgamma::set_parameters</ref><sp/>(<sp/></highlight><highlight class="keywordtype">double</highlight><highlight class="normal"><sp/>k0<sp/>)<sp/>{</highlight></codeline>
<codeline lineno="109"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="classmgamma_143f733cce0245a52363d566099add687" kindref="member" tooltip="Constant .">k</ref>=k0;</highlight></codeline>
<codeline lineno="110"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="classmpdf_17aa894208a32f3487827df6d5054424c" kindref="member" tooltip="pointer to internal epdf">ep</ref><sp/>=<sp/>&amp;<ref refid="classepdf" kindref="compound" tooltip="Probability density function with numerical statistics, e.g. posterior density.">epdf</ref>;</highlight></codeline>
<codeline lineno="111"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="classepdf" kindref="compound" tooltip="Probability density function with numerical statistics, e.g. posterior density.">epdf</ref>.set_parameters<sp/>(<sp/><ref refid="classmgamma_143f733cce0245a52363d566099add687" kindref="member" tooltip="Constant .">k</ref>*ones<sp/>(<sp/><ref refid="classmpdf_1f6687c07ff07d47812dd565368ca59eb" kindref="member" tooltip="modeled random variable">rv</ref>.<ref refid="classRV_1f5c7b8bd589eef09ccdf3329a0addea0" kindref="member" tooltip="Return number of scalars in the RV.">count</ref>()<sp/>),*<ref refid="classmgamma_15e90652837448bcc29707e7412f99691" kindref="member" tooltip="cache of epdf.beta">_beta</ref><sp/>);</highlight></codeline>
<codeline lineno="112"><highlight class="normal">};</highlight></codeline>
<codeline lineno="113"><highlight class="normal"></highlight></codeline>
<codeline lineno="114" refid="classeEmp_177268292fc4465cb73ddbfb1f2932a59" refkind="member"><highlight class="normal">ivec<sp/><ref refid="classeEmp_177268292fc4465cb73ddbfb1f2932a59" kindref="member" tooltip="Function performs resampling, i.e. removal of low-weight samples and duplication...">eEmp::resample</ref><sp/>(<sp/><ref refid="libEF_8h_199497a3ff630f761cf6bff7babd23212" kindref="member" tooltip="Switch between various resampling methods.">RESAMPLING_METHOD</ref><sp/>method<sp/>)<sp/>{</highlight></codeline>
<codeline lineno="115"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>ivec<sp/>ind=zeros_i<sp/>(<sp/><ref refid="classeEmp_18c33034de0e35f03f8bb85d3d67438fd" kindref="member" tooltip="Number of particles.">n</ref><sp/>);</highlight></codeline>
<codeline lineno="116"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>ivec<sp/>N_babies<sp/>=<sp/>zeros_i<sp/>(<sp/><ref refid="classeEmp_18c33034de0e35f03f8bb85d3d67438fd" kindref="member" tooltip="Number of particles.">n</ref><sp/>);</highlight></codeline>
<codeline lineno="117"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>vec<sp/>cumDist<sp/>=<sp/>cumsum<sp/>(<sp/><ref refid="classeEmp_1ae78d144404ddba843c93b171b215de8" kindref="member" tooltip="Sample weights .">w</ref><sp/>);</highlight></codeline>
<codeline lineno="118"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>vec<sp/>u<sp/>(<sp/><ref refid="classeEmp_18c33034de0e35f03f8bb85d3d67438fd" kindref="member" tooltip="Number of particles.">n</ref><sp/>);</highlight></codeline>
<codeline lineno="119"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>i,j,parent;</highlight></codeline>
<codeline lineno="120"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordtype">double</highlight><highlight class="normal"><sp/>u0;</highlight></codeline>
<codeline lineno="121"><highlight class="normal"></highlight></codeline>
<codeline lineno="122"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">switch</highlight><highlight class="normal"><sp/>(<sp/>method<sp/>)<sp/>{</highlight></codeline>
<codeline lineno="123"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">case</highlight><highlight class="normal"><sp/>MULTINOMIAL:</highlight></codeline>
<codeline lineno="124"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>u<sp/>(<sp/><ref refid="classeEmp_18c33034de0e35f03f8bb85d3d67438fd" kindref="member" tooltip="Number of particles.">n</ref><sp/>-<sp/>1<sp/>)<sp/>=<sp/>pow<sp/>(<sp/>UniRNG.sample(),<sp/>1.0<sp/>/<sp/><ref refid="classeEmp_18c33034de0e35f03f8bb85d3d67438fd" kindref="member" tooltip="Number of particles.">n</ref><sp/>);</highlight></codeline>
<codeline lineno="125"><highlight class="normal"></highlight></codeline>
<codeline lineno="126"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">for</highlight><highlight class="normal"><sp/>(<sp/>i<sp/>=<sp/><ref refid="classeEmp_18c33034de0e35f03f8bb85d3d67438fd" kindref="member" tooltip="Number of particles.">n</ref><sp/>-<sp/>2;i<sp/>&gt;=<sp/>0;i--<sp/>)<sp/>{</highlight></codeline>
<codeline lineno="127"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>u<sp/>(<sp/>i<sp/>)<sp/>=<sp/>u<sp/>(<sp/>i<sp/>+<sp/>1<sp/>)<sp/>*<sp/>pow<sp/>(<sp/>UniRNG.sample(),<sp/>1.0<sp/>/<sp/>(<sp/>i<sp/>+<sp/>1<sp/>)<sp/>);</highlight></codeline>
<codeline lineno="128"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="129"><highlight class="normal"></highlight></codeline>
<codeline lineno="130"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="131"><highlight class="normal"></highlight></codeline>
<codeline lineno="132"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">case</highlight><highlight class="normal"><sp/>STRATIFIED:</highlight></codeline>
<codeline lineno="133"><highlight class="normal"></highlight></codeline>
<codeline lineno="134"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">for</highlight><highlight class="normal"><sp/>(<sp/>i<sp/>=<sp/>0;i<sp/>&lt;<sp/><ref refid="classeEmp_18c33034de0e35f03f8bb85d3d67438fd" kindref="member" tooltip="Number of particles.">n</ref>;i++<sp/>)<sp/>{</highlight></codeline>
<codeline lineno="135"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>u<sp/>(<sp/>i<sp/>)<sp/>=<sp/>(<sp/>i<sp/>+<sp/>UniRNG.sample()<sp/>)<sp/>/<sp/>n;</highlight></codeline>
<codeline lineno="136"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="137"><highlight class="normal"></highlight></codeline>
<codeline lineno="138"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="139"><highlight class="normal"></highlight></codeline>
<codeline lineno="140"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">case</highlight><highlight class="normal"><sp/>SYSTEMATIC:</highlight></codeline>
<codeline lineno="141"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>u0<sp/>=<sp/>UniRNG.sample();</highlight></codeline>
<codeline lineno="142"><highlight class="normal"></highlight></codeline>
<codeline lineno="143"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">for</highlight><highlight class="normal"><sp/>(<sp/>i<sp/>=<sp/>0;i<sp/>&lt;<sp/>n;i++<sp/>)<sp/>{</highlight></codeline>
<codeline lineno="144"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>u<sp/>(<sp/>i<sp/>)<sp/>=<sp/>(<sp/>i<sp/>+<sp/>u0<sp/>)<sp/>/<sp/>n;</highlight></codeline>
<codeline lineno="145"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="146"><highlight class="normal"></highlight></codeline>
<codeline lineno="147"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="148"><highlight class="normal"></highlight></codeline>
<codeline lineno="149"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">default</highlight><highlight class="normal">:</highlight></codeline>
<codeline lineno="150"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>it_error<sp/>(<sp/></highlight><highlight class="stringliteral">&quot;PF::resample():<sp/>Unknown<sp/>resampling<sp/>method&quot;</highlight><highlight class="normal"><sp/>);</highlight></codeline>
<codeline lineno="151"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="152"><highlight class="normal"></highlight></codeline>
<codeline lineno="153"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">//<sp/>U<sp/>is<sp/>now<sp/>full</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="154"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>j<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="155"><highlight class="normal"></highlight></codeline>
<codeline lineno="156"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">for</highlight><highlight class="normal"><sp/>(<sp/>i<sp/>=<sp/>0;i<sp/>&lt;<sp/><ref refid="classeEmp_18c33034de0e35f03f8bb85d3d67438fd" kindref="member" tooltip="Number of particles.">n</ref>;i++<sp/>)<sp/>{</highlight></codeline>
<codeline lineno="157"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">while</highlight><highlight class="normal"><sp/>(<sp/>u<sp/>(<sp/>i<sp/>)<sp/>&gt;<sp/>cumDist<sp/>(<sp/>j<sp/>)<sp/>)<sp/>j++;</highlight></codeline>
<codeline lineno="158"><highlight class="normal"></highlight></codeline>
<codeline lineno="159"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>N_babies<sp/>(<sp/>j<sp/>)<sp/>++;</highlight></codeline>
<codeline lineno="160"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="161"><highlight class="normal"></highlight></codeline>
<codeline lineno="162"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">//<sp/>We<sp/>have<sp/>assigned<sp/>new<sp/>babies<sp/>for<sp/>each<sp/>Particle</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="163"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">//<sp/>Now,<sp/>we<sp/>fill<sp/>the<sp/>resulting<sp/>index<sp/>such<sp/>that:</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="164"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">//<sp/>*<sp/>particles<sp/>with<sp/>at<sp/>least<sp/>one<sp/>baby<sp/>should<sp/>not<sp/>move<sp/>*</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="165"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">//<sp/>This<sp/>assures<sp/>that<sp/>reassignment<sp/>can<sp/>be<sp/>done<sp/>inplace;</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="166"><highlight class="normal"></highlight></codeline>
<codeline lineno="167"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">//<sp/>find<sp/>the<sp/>first<sp/>parent;</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="168"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>parent=0;<sp/></highlight><highlight class="keywordflow">while</highlight><highlight class="normal"><sp/>(<sp/>N_babies<sp/>(<sp/>parent<sp/>)<sp/>==0<sp/>)<sp/>parent++;</highlight></codeline>
<codeline lineno="169"><highlight class="normal"></highlight></codeline>
<codeline lineno="170"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">//<sp/>Build<sp/>index</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="171"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">for</highlight><highlight class="normal"><sp/>(<sp/>i<sp/>=<sp/>0;i<sp/>&lt;<sp/>n;i++<sp/>)<sp/>{</highlight></codeline>
<codeline lineno="172"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(<sp/>N_babies<sp/>(<sp/>i<sp/>)<sp/>&gt;<sp/>0<sp/>)<sp/>{</highlight></codeline>
<codeline lineno="173"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>ind<sp/>(<sp/>i<sp/>)<sp/>=<sp/>i;</highlight></codeline>
<codeline lineno="174"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>N_babies<sp/>(<sp/>i<sp/>)<sp/>--;<sp/></highlight><highlight class="comment">//this<sp/>index<sp/>was<sp/>now<sp/>replicated;</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="175"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="176"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">//<sp/>test<sp/>if<sp/>the<sp/>parent<sp/>has<sp/>been<sp/>fully<sp/>replicated</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="177"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">//<sp/>if<sp/>yes,<sp/>find<sp/>the<sp/>next<sp/>one</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="178"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">while</highlight><highlight class="normal"><sp/>(<sp/>(<sp/>N_babies<sp/>(<sp/>parent<sp/>)<sp/>==0<sp/>)<sp/>||<sp/>(<sp/>N_babies<sp/>(<sp/>parent<sp/>)<sp/>==1<sp/>&amp;&amp;<sp/>parent&gt;i<sp/>)<sp/>)<sp/>parent++;</highlight></codeline>
<codeline lineno="179"><highlight class="normal"></highlight></codeline>
<codeline lineno="180"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">//<sp/>Replicate<sp/>parent</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="181"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>ind<sp/>(<sp/>i<sp/>)<sp/>=<sp/>parent;</highlight></codeline>
<codeline lineno="182"><highlight class="normal"></highlight></codeline>
<codeline lineno="183"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>N_babies<sp/>(<sp/>parent<sp/>)<sp/>--;<sp/></highlight><highlight class="comment">//this<sp/>index<sp/>was<sp/>now<sp/>replicated;</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="184"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="185"><highlight class="normal"></highlight></codeline>
<codeline lineno="186"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="187"><highlight class="normal"></highlight></codeline>
<codeline lineno="188"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">//<sp/>copy<sp/>the<sp/>internals<sp/>according<sp/>to<sp/>ind</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="189"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">for</highlight><highlight class="normal"><sp/>(<sp/>i=0;i&lt;n;i++<sp/>)<sp/>{</highlight></codeline>
<codeline lineno="190"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(<sp/>ind<sp/>(<sp/>i<sp/>)<sp/>!=i<sp/>)<sp/>{</highlight></codeline>
<codeline lineno="191"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="classeEmp_1a4d6f4bbd6a6824fc39f14676701279a" kindref="member" tooltip="Samples .">samples</ref><sp/>(<sp/>i<sp/>)<sp/>=<ref refid="classeEmp_1a4d6f4bbd6a6824fc39f14676701279a" kindref="member" tooltip="Samples .">samples</ref><sp/>(<sp/>ind<sp/>(<sp/>i<sp/>)<sp/>);</highlight></codeline>
<codeline lineno="192"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="193"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="classeEmp_1ae78d144404ddba843c93b171b215de8" kindref="member" tooltip="Sample weights .">w</ref><sp/>(<sp/>i<sp/>)<sp/>=<sp/>1.0/n;</highlight></codeline>
<codeline lineno="194"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="195"><highlight class="normal"></highlight></codeline>
<codeline lineno="196"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>ind;</highlight></codeline>
<codeline lineno="197"><highlight class="normal">}</highlight></codeline>
<codeline lineno="198"><highlight class="normal"></highlight></codeline>
<codeline lineno="199" refid="classeEmp_16606a656c1b28114f7384c25aaf80e8d" refkind="member"><highlight class="normal"></highlight><highlight class="keywordtype">void</highlight><highlight class="normal"><sp/><ref refid="classeEmp_16606a656c1b28114f7384c25aaf80e8d" kindref="member" tooltip="Set sample.">eEmp::set_parameters</ref><sp/>(<sp/></highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/>vec<sp/>&amp;w0,<sp/><ref refid="classepdf" kindref="compound" tooltip="Probability density function with numerical statistics, e.g. posterior density.">epdf</ref>*<sp/>epdf0<sp/>)<sp/>{</highlight></codeline>
<codeline lineno="200"><highlight class="normal"></highlight><highlight class="comment">//it_assert_debug(rv==epdf0-&gt;rv(),&quot;Wrong<sp/>epdf0&quot;);</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="201"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="classeEmp_1ae78d144404ddba843c93b171b215de8" kindref="member" tooltip="Sample weights .">w</ref>=w0;</highlight></codeline>
<codeline lineno="202"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="classeEmp_1ae78d144404ddba843c93b171b215de8" kindref="member" tooltip="Sample weights .">w</ref>/=sum<sp/>(<sp/>w0<sp/>);</highlight><highlight class="comment">//renormalize</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="203"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="classeEmp_18c33034de0e35f03f8bb85d3d67438fd" kindref="member" tooltip="Number of particles.">n</ref>=<ref refid="classeEmp_1ae78d144404ddba843c93b171b215de8" kindref="member" tooltip="Sample weights .">w</ref>.length();</highlight></codeline>
<codeline lineno="204"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="classeEmp_1a4d6f4bbd6a6824fc39f14676701279a" kindref="member" tooltip="Samples .">samples</ref>.set_size<sp/>(<sp/><ref refid="classeEmp_18c33034de0e35f03f8bb85d3d67438fd" kindref="member" tooltip="Number of particles.">n</ref><sp/>);</highlight></codeline>
<codeline lineno="205"><highlight class="normal"></highlight></codeline>
<codeline lineno="206"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">for</highlight><highlight class="normal"><sp/>(<sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>i=0;i&lt;<ref refid="classeEmp_18c33034de0e35f03f8bb85d3d67438fd" kindref="member" tooltip="Number of particles.">n</ref>;i++<sp/>)<sp/>{<ref refid="classeEmp_1a4d6f4bbd6a6824fc39f14676701279a" kindref="member" tooltip="Samples .">samples</ref><sp/>(<sp/>i<sp/>)<sp/>=epdf0-&gt;<ref refid="classepdf_18019654e494bf5e458f6fb947e11b262" kindref="member" tooltip="Returns the required moment of the epdf.">sample</ref>();}</highlight></codeline>
<codeline lineno="207"><highlight class="normal">}</highlight></codeline>
    </programlisting>
    <location file="/home/smidl/work/git/mixpp/bdm/stat/libEF.cpp"/>
  </compounddef>
</doxygen>
