<?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="emix_8h" kind="file">
    <compoundname>emix.h</compoundname>
    <includes refid="libBM_8h" local="yes">libBM.h</includes>
    <includes refid="libEF_8h" local="yes">libEF.h</includes>
    <includedby refid="emix_8cpp" local="yes">work/git/mixpp/bdm/stat/emix.cpp</includedby>
    <includedby refid="merger_8h" local="yes">work/git/mixpp/bdm/stat/merger.h</includedby>
    <includedby refid="pmsm__mix_8cpp" local="no">work/git/mixpp/pmsm/pmsm_mix.cpp</includedby>
    <includedby refid="testSmp_8cpp" local="no">work/git/mixpp/tests/testSmp.cpp</includedby>
    <incdepgraph>
      <node id="342">
        <label>libBM.h</label>
        <link refid="libBM_8h"/>
        <childnode refid="343" relation="include">
        </childnode>
      </node>
      <node id="341">
        <label>work/git/mixpp/bdm/stat/emix.h</label>
        <link refid="emix.h"/>
        <childnode refid="342" relation="include">
        </childnode>
        <childnode refid="344" relation="include">
        </childnode>
      </node>
      <node id="346">
        <label>../itpp_ext.h</label>
        <link refid="itpp__ext_8h-source"/>
        <childnode refid="343" relation="include">
        </childnode>
      </node>
      <node id="344">
        <label>libEF.h</label>
        <link refid="libEF_8h"/>
        <childnode refid="343" relation="include">
        </childnode>
        <childnode refid="345" relation="include">
        </childnode>
        <childnode refid="342" relation="include">
        </childnode>
        <childnode refid="346" relation="include">
        </childnode>
      </node>
      <node id="343">
        <label>itpp/itbase.h</label>
      </node>
      <node id="345">
        <label>../math/libDC.h</label>
        <link refid="libDC_8h"/>
        <childnode refid="343" relation="include">
        </childnode>
      </node>
    </incdepgraph>
    <invincdepgraph>
      <node id="348">
        <label>work/git/mixpp/bdm/stat/merger.h</label>
        <link refid="merger_8h"/>
      </node>
      <node id="347">
        <label>work/git/mixpp/bdm/stat/emix.h</label>
        <link refid="emix.h"/>
        <childnode refid="348" relation="include">
        </childnode>
        <childnode refid="349" relation="include">
        </childnode>
      </node>
      <node id="349">
        <label>work/git/mixpp/pmsm/pmsm_mix.cpp</label>
        <link refid="pmsm__mix_8cpp"/>
      </node>
    </invincdepgraph>
    <innerclass refid="classemix" prot="public">emix</innerclass>
    <innerclass refid="classmprod" prot="public">mprod</innerclass>
    <innerclass refid="classmmix" prot="public">mmix</innerclass>
    <briefdescription>
<para>Probability distributions for Mixtures of pdfs. </para>    </briefdescription>
    <detaileddescription>
<para><simplesect kind="author"><para>Vaclav Smidl.</para></simplesect>
----------------------------------- BDM++ - C++ library for Bayesian Decision Making under Uncertainty</para><para>Using IT++ for numerical operations ----------------------------------- </para>    </detaileddescription>
    <programlisting>
<codeline lineno="1"></codeline>
<codeline lineno="13"><highlight class="preprocessor">#ifndef<sp/>MX_H</highlight></codeline>
<codeline lineno="14"><highlight class="preprocessor"></highlight><highlight class="preprocessor">#define<sp/>MX_H</highlight></codeline>
<codeline lineno="15"><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="16"><highlight class="normal"></highlight><highlight class="preprocessor">#include<sp/>&quot;<ref refid="libBM_8h" kindref="compound" tooltip="Bayesian Models (bm) that use Bayes rule to learn from observations.">libBM.h</ref>&quot;</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="17"><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="18"><highlight class="normal"></highlight><highlight class="comment">//#include<sp/>&lt;std&gt;</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="19"><highlight class="normal"></highlight></codeline>
<codeline lineno="20"><highlight class="normal"></highlight><highlight class="keyword">using<sp/>namespace<sp/></highlight><highlight class="normal">itpp;</highlight></codeline>
<codeline lineno="21"><highlight class="normal"></highlight></codeline>
<codeline lineno="32" refid="classemix" refkind="compound"><highlight class="keyword">class<sp/></highlight><highlight class="normal"><ref refid="classemix" kindref="compound" tooltip="Mixture of epdfs.">emix</ref><sp/>:<sp/></highlight><highlight class="keyword">public</highlight><highlight class="normal"><sp/><ref refid="classepdf" kindref="compound" tooltip="Probability density function with numerical statistics, e.g. posterior density.">epdf</ref><sp/>{</highlight></codeline>
<codeline lineno="33"><highlight class="normal"></highlight><highlight class="keyword">protected</highlight><highlight class="normal">:</highlight></codeline>
<codeline lineno="35" refid="classemix_1cdc8f4e2a5e43595ac5450d8a7f9d1ab" refkind="member"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>vec<sp/><ref refid="classemix_1cdc8f4e2a5e43595ac5450d8a7f9d1ab" kindref="member" tooltip="weights of the components">w</ref>;</highlight></codeline>
<codeline lineno="37" refid="classemix_17155d827417b53fb6aa5cff1459e6eb4" refkind="member"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>Array&lt;epdf*&gt;<sp/><ref refid="classemix_17155d827417b53fb6aa5cff1459e6eb4" kindref="member" tooltip="Component (epdfs).">Coms</ref>;</highlight></codeline>
<codeline lineno="38"><highlight class="normal"></highlight><highlight class="keyword">public</highlight><highlight class="normal">:</highlight></codeline>
<codeline lineno="40" refid="classemix_13a10c8481115a5460877272ddb6532a6" refkind="member"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="classemix_13a10c8481115a5460877272ddb6532a6" kindref="member" tooltip="Default constructor.">emix</ref><sp/>(<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><sp/>)<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/>{};</highlight></codeline>
<codeline lineno="42"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordtype">void</highlight><highlight class="normal"><sp/><ref refid="classemix_16ce82b24d7fe540ddbf44b472a005555" kindref="member" tooltip="Set weights w and components R.">set_parameters</ref><sp/>(<sp/></highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/>vec<sp/>&amp;<ref refid="classemix_1cdc8f4e2a5e43595ac5450d8a7f9d1ab" kindref="member" tooltip="weights of the components">w</ref>,<sp/></highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/>Array&lt;epdf*&gt;<sp/>&amp;<ref refid="classemix_17155d827417b53fb6aa5cff1459e6eb4" kindref="member" tooltip="Component (epdfs).">Coms</ref><sp/>);</highlight></codeline>
<codeline lineno="43"><highlight class="normal"></highlight></codeline>
<codeline lineno="44"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>vec<sp/><ref refid="classemix_10650601f24e633e0ab09aa1e46c14483" kindref="member" tooltip="Returns the required moment of the epdf.">sample</ref>()<sp/></highlight><highlight class="keyword">const</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="45" refid="classemix_1b662a51d042b062020460e64bff4e9e8" refkind="member"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>vec<sp/><ref refid="classemix_1b662a51d042b062020460e64bff4e9e8" kindref="member" tooltip="return expected value">mean</ref>()</highlight><highlight class="keyword"><sp/>const<sp/></highlight><highlight class="normal">{</highlight></codeline>
<codeline lineno="46"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>i;<sp/>vec<sp/>mu<sp/>=<sp/>zeros<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="47"><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="classemix_1cdc8f4e2a5e43595ac5450d8a7f9d1ab" kindref="member" tooltip="weights of the components">w</ref>.length();i++<sp/>)<sp/>{mu<sp/>+=<sp/><ref refid="classemix_1cdc8f4e2a5e43595ac5450d8a7f9d1ab" kindref="member" tooltip="weights of the components">w</ref><sp/>(<sp/>i<sp/>)<sp/>*<sp/><ref refid="classemix_17155d827417b53fb6aa5cff1459e6eb4" kindref="member" tooltip="Component (epdfs).">Coms</ref><sp/>(<sp/>i<sp/>)-&gt;mean();<sp/>}</highlight></codeline>
<codeline lineno="48"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>mu;</highlight></codeline>
<codeline lineno="49"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="50" refid="classemix_1469e910479b3402589104ef3bb1b5741" refkind="member"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordtype">double</highlight><highlight class="normal"><sp/><ref refid="classemix_1469e910479b3402589104ef3bb1b5741" kindref="member" tooltip="Compute log-probability of argument val.">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="51"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>i;</highlight></codeline>
<codeline lineno="52"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordtype">double</highlight><highlight class="normal"><sp/>sum<sp/>=<sp/>0.0;</highlight></codeline>
<codeline lineno="53"><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="classemix_1cdc8f4e2a5e43595ac5450d8a7f9d1ab" kindref="member" tooltip="weights of the components">w</ref>.length();i++<sp/>)<sp/>{sum<sp/>+=<sp/><ref refid="classemix_1cdc8f4e2a5e43595ac5450d8a7f9d1ab" kindref="member" tooltip="weights of the components">w</ref><sp/>(<sp/>i<sp/>)<sp/>*<sp/><ref refid="classemix_17155d827417b53fb6aa5cff1459e6eb4" kindref="member" tooltip="Component (epdfs).">Coms</ref><sp/>(<sp/>i<sp/>)-&gt;evalpdflog<sp/>(<sp/>val<sp/>);}</highlight></codeline>
<codeline lineno="54"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>log<sp/>(<sp/>sum<sp/>);</highlight></codeline>
<codeline lineno="55"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>};</highlight></codeline>
<codeline lineno="56"><highlight class="normal"></highlight></codeline>
<codeline lineno="57"><highlight class="normal"></highlight><highlight class="comment">//Access<sp/>methods</highlight></codeline>
<codeline lineno="59" refid="classemix_135baf0f62307455cebfbf462144b4dd8" refkind="member"><highlight class="comment"></highlight><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>vec&amp;<sp/><ref refid="classemix_135baf0f62307455cebfbf462144b4dd8" kindref="member" tooltip="returns a pointer to the internal mean value. Use with Care!">_w</ref>()<sp/>{</highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/><ref refid="classemix_1cdc8f4e2a5e43595ac5450d8a7f9d1ab" kindref="member" tooltip="weights of the components">w</ref>;}</highlight></codeline>
<codeline lineno="60"><highlight class="normal">};</highlight></codeline>
<codeline lineno="61"><highlight class="normal"></highlight></codeline>
<codeline lineno="70" refid="classmprod" refkind="compound"><highlight class="keyword">class<sp/></highlight><highlight class="normal"><ref refid="classmprod" kindref="compound" tooltip="Chain rule decomposition of epdf.">mprod</ref>:<sp/></highlight><highlight class="keyword">public</highlight><highlight class="normal"><sp/><ref refid="classmpdf" kindref="compound" tooltip="Conditional probability density, e.g. modeling some dependencies.">mpdf</ref><sp/>{</highlight></codeline>
<codeline lineno="71"><highlight class="normal"></highlight><highlight class="keyword">protected</highlight><highlight class="normal">:</highlight></codeline>
<codeline lineno="72"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">//</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="73"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>n;</highlight></codeline>
<codeline lineno="74"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">//<sp/>pointers<sp/>to<sp/>epdfs</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="75"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>Array&lt;epdf*&gt;<sp/>epdfs;</highlight></codeline>
<codeline lineno="76"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>Array&lt;mpdf*&gt;<sp/>mpdfs;</highlight></codeline>
<codeline lineno="77"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">//</highlight></codeline>
<codeline lineno="79" refid="classmprod_1c8f78fbcdb4e38ecd3197d2958082497" refkind="member"><highlight class="comment"></highlight><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>Array&lt;ivec&gt;<sp/><ref refid="classmprod_1c8f78fbcdb4e38ecd3197d2958082497" kindref="member" tooltip="Indeces of rvs in common rv.">rvinds</ref>;</highlight></codeline>
<codeline lineno="81" refid="classmprod_11725c7b497a27ab3c4889b846666b516" refkind="member"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>Array&lt;ivec&gt;<sp/><ref refid="classmprod_11725c7b497a27ab3c4889b846666b516" kindref="member" tooltip="Indeces of rvc in common rv.">rvcinrv</ref>;</highlight></codeline>
<codeline lineno="83" refid="classmprod_1cc85192d8abc01832937ed8b62e363a6" refkind="member"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>Array&lt;ivec&gt;<sp/><ref refid="classmprod_1cc85192d8abc01832937ed8b62e363a6" kindref="member" tooltip="Indeces of rvc in common rvc.">rvcinds</ref>;</highlight></codeline>
<codeline lineno="85" refid="classmprod_15f6431dc5f5ce8a817e0b2049f2a9eda" refkind="member"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordtype">bool</highlight><highlight class="normal"><sp/><ref refid="classmprod_15f6431dc5f5ce8a817e0b2049f2a9eda" kindref="member" tooltip="Indicate independence of its factors.">independent</ref>;</highlight></codeline>
<codeline lineno="86"><highlight class="normal"></highlight><highlight class="comment">//<sp/><sp/><sp/><sp/><sp/><sp/>//!<sp/>Indicate<sp/>internal<sp/>creation<sp/>of<sp/>mpdfs<sp/>which<sp/>must<sp/>be<sp/>destroyed</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="87"><highlight class="normal"></highlight><highlight class="comment">//<sp/><sp/><sp/><sp/><sp/><sp/>bool<sp/>intermpdfs;</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="88"><highlight class="normal"></highlight><highlight class="keyword">public</highlight><highlight class="normal">:</highlight></codeline>
<codeline lineno="90" refid="classmprod_1419b303581a91ad85200bdcb4b3186f4" refkind="member"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="classmprod_1419b303581a91ad85200bdcb4b3186f4" kindref="member" tooltip="Constructor from list of eFacs or list of mFacs.">mprod</ref><sp/>(<sp/>Array&lt;mpdf*&gt;<sp/>mFacs<sp/>)<sp/>:<sp/><ref refid="classmpdf" kindref="compound" tooltip="Conditional probability density, e.g. modeling some dependencies.">mpdf</ref><sp/>(<sp/><ref refid="classRV" kindref="compound" tooltip="Class representing variables, most often random variables.">RV</ref>(),<sp/><ref refid="classRV" kindref="compound" tooltip="Class representing variables, most often random variables.">RV</ref>()<sp/>),<sp/>n<sp/>(<sp/>mFacs.length()<sp/>),<sp/>epdfs<sp/>(<sp/>n<sp/>),<sp/>mpdfs<sp/>(<sp/>mFacs<sp/>),<sp/><ref refid="classmprod_1c8f78fbcdb4e38ecd3197d2958082497" kindref="member" tooltip="Indeces of rvs in common rv.">rvinds</ref><sp/>(<sp/>n<sp/>),<sp/><ref refid="classmprod_11725c7b497a27ab3c4889b846666b516" kindref="member" tooltip="Indeces of rvc in common rv.">rvcinrv</ref><sp/>(<sp/>n<sp/>),<sp/><ref refid="classmprod_1cc85192d8abc01832937ed8b62e363a6" kindref="member" tooltip="Indeces of rvc in common rvc.">rvcinds</ref><sp/>(<sp/>n<sp/>)<sp/>{</highlight></codeline>
<codeline lineno="91"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>i;</highlight></codeline>
<codeline lineno="92"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">//<sp/>Create<sp/>rv</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="93"><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="94"><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="classmpdf_1f6687c07ff07d47812dd565368ca59eb" kindref="member" tooltip="modeled random variable">rv</ref>.<ref refid="classRV_1935790526b630dec4ffefa9ec0c2b6fb" kindref="member" tooltip="Add (concat) another variable to the current one,.">add</ref><sp/>(<sp/>mpdfs<sp/>(<sp/>i<sp/>)-&gt;<ref refid="classmpdf_11e71ad4c66d5884c82d4a3b06b42fe32" kindref="member" tooltip="access function">_rv</ref>()<sp/>);<sp/></highlight><highlight class="comment">//add<sp/>rv<sp/>to<sp/>common<sp/>rvs.</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="95"><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/>epdfs<sp/>(<sp/>i<sp/>)<sp/>=<sp/>&amp;<sp/>(<sp/>mpdfs<sp/>(<sp/>i<sp/>)-&gt;_epdf()<sp/>);<sp/></highlight><highlight class="comment">//<sp/>add<sp/>pointer<sp/>to<sp/>epdf</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="96"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>};</highlight></codeline>
<codeline lineno="97"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">//<sp/>Create<sp/>rvc</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="98"><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="99"><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="classmpdf_1acb7dda792b3cd5576f39fa3129abbab" kindref="member" tooltip="random variable in condition">rvc</ref>.<ref refid="classRV_1935790526b630dec4ffefa9ec0c2b6fb" kindref="member" tooltip="Add (concat) another variable to the current one,.">add</ref><sp/>(<sp/>mpdfs<sp/>(<sp/>i<sp/>)-&gt;<ref refid="classmpdf_11e71ad4c66d5884c82d4a3b06b42fe32" kindref="member" tooltip="access function">_rv</ref>().subt<sp/>(<sp/><ref refid="classmpdf_1f6687c07ff07d47812dd565368ca59eb" kindref="member" tooltip="modeled random variable">rv</ref><sp/>)<sp/>);<sp/></highlight><highlight class="comment">//add<sp/>rv<sp/>to<sp/>common<sp/>rvs.</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="100"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><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/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="classmprod_15f6431dc5f5ce8a817e0b2049f2a9eda" kindref="member" tooltip="Indicate independence of its factors.">independent</ref><sp/>=<sp/></highlight><highlight class="keyword">true</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="103"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">//test<sp/>rvc<sp/>of<sp/>mpdfs<sp/>and<sp/>fill<sp/>rvinds</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="104"><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="105"><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/>find<sp/>ith<sp/>rv<sp/>in<sp/>common<sp/>rv</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="106"><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="classmprod_1c8f78fbcdb4e38ecd3197d2958082497" kindref="member" tooltip="Indeces of rvs in common rv.">rvinds</ref><sp/>(<sp/>i<sp/>)<sp/>=<sp/>mpdfs<sp/>(<sp/>i<sp/>)-&gt;_rv().dataind<sp/>(<sp/><ref refid="classmpdf_1f6687c07ff07d47812dd565368ca59eb" kindref="member" tooltip="modeled random variable">rv</ref><sp/>);</highlight></codeline>
<codeline lineno="107"><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/>find<sp/>ith<sp/>rvc<sp/>in<sp/>common<sp/>rv</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="108"><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="classmprod_11725c7b497a27ab3c4889b846666b516" kindref="member" tooltip="Indeces of rvc in common rv.">rvcinrv</ref><sp/>(<sp/>i<sp/>)<sp/>=<sp/>mpdfs<sp/>(<sp/>i<sp/>)-&gt;_rvc().dataind<sp/>(<sp/><ref refid="classmpdf_1f6687c07ff07d47812dd565368ca59eb" kindref="member" tooltip="modeled random variable">rv</ref><sp/>);</highlight></codeline>
<codeline lineno="109"><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/>find<sp/>ith<sp/>rvc<sp/>in<sp/>common<sp/>rv</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="110"><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="classmprod_1cc85192d8abc01832937ed8b62e363a6" kindref="member" tooltip="Indeces of rvc in common rvc.">rvcinds</ref><sp/>(<sp/>i<sp/>)<sp/>=<sp/>mpdfs<sp/>(<sp/>i<sp/>)-&gt;_rvc().dataind<sp/>(<sp/><ref refid="classmpdf_1acb7dda792b3cd5576f39fa3129abbab" kindref="member" tooltip="random variable in condition">rvc</ref><sp/>);</highlight></codeline>
<codeline lineno="111"><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">//</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="112"><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">if</highlight><highlight class="normal"><sp/>(<sp/><ref refid="classmprod_1cc85192d8abc01832937ed8b62e363a6" kindref="member" tooltip="Indeces of rvc in common rvc.">rvcinds</ref><sp/>(<sp/>i<sp/>).length()<sp/>&gt;0<sp/>)<sp/>{<ref refid="classmprod_15f6431dc5f5ce8a817e0b2049f2a9eda" kindref="member" tooltip="Indicate independence of its factors.">independent</ref><sp/>=<sp/></highlight><highlight class="keyword">false</highlight><highlight class="normal">;}</highlight></codeline>
<codeline lineno="113"><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">if</highlight><highlight class="normal"><sp/>(<sp/><ref refid="classmprod_1cc85192d8abc01832937ed8b62e363a6" kindref="member" tooltip="Indeces of rvc in common rvc.">rvcinds</ref><sp/>(<sp/>i<sp/>).length()<sp/>&gt;0<sp/>)<sp/>{<ref refid="classmprod_15f6431dc5f5ce8a817e0b2049f2a9eda" kindref="member" tooltip="Indicate independence of its factors.">independent</ref><sp/>=<sp/></highlight><highlight class="keyword">false</highlight><highlight class="normal">;}</highlight></codeline>
<codeline lineno="114"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="115"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>};</highlight></codeline>
<codeline lineno="116"><highlight class="normal"></highlight></codeline>
<codeline lineno="117"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordtype">double</highlight><highlight class="normal"><sp/>evalpdflog<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="118"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>i;</highlight></codeline>
<codeline lineno="119"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordtype">double</highlight><highlight class="normal"><sp/>res<sp/>=<sp/>0.0;</highlight></codeline>
<codeline lineno="120"><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/>n<sp/>-<sp/>1;i<sp/>&gt;<sp/>0;i++<sp/>)<sp/>{</highlight></codeline>
<codeline lineno="121"><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">if</highlight><highlight class="normal"><sp/>(<sp/><ref refid="classmprod_1cc85192d8abc01832937ed8b62e363a6" kindref="member" tooltip="Indeces of rvc in common rvc.">rvcinds</ref><sp/>(<sp/>i<sp/>).length()<sp/>&gt;<sp/>0<sp/>)</highlight></codeline>
<codeline lineno="122"><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/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>{mpdfs<sp/>(<sp/>i<sp/>)-&gt;condition<sp/>(<sp/>val<sp/>(<sp/><ref refid="classmprod_1cc85192d8abc01832937ed8b62e363a6" kindref="member" tooltip="Indeces of rvc in common rvc.">rvcinds</ref><sp/>(<sp/>i<sp/>)<sp/>)<sp/>);}</highlight></codeline>
<codeline lineno="123"><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/>add<sp/>logarithms</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="124"><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/>res<sp/>+=<sp/>epdfs<sp/>(<sp/>i<sp/>)-&gt;evalpdflog<sp/>(<sp/>val<sp/>(<sp/><ref refid="classmprod_1c8f78fbcdb4e38ecd3197d2958082497" kindref="member" tooltip="Indeces of rvs in common rv.">rvinds</ref><sp/>(<sp/>i<sp/>)<sp/>)<sp/>);</highlight></codeline>
<codeline lineno="125"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</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">return</highlight><highlight class="normal"><sp/>res;</highlight></codeline>
<codeline lineno="127"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="128"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>vec<sp/>samplecond<sp/>(<sp/></highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/>vec<sp/>&amp;cond,<sp/>vec<sp/>&amp;ll<sp/>)</highlight><highlight class="keyword"><sp/>const<sp/></highlight><highlight class="normal">{</highlight></codeline>
<codeline lineno="129"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>vec<sp/>smp=zeros<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/>);</highlight></codeline>
<codeline lineno="130"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>vec<sp/>condi;</highlight></codeline>
<codeline lineno="131"><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/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>i<sp/>=<sp/>(<sp/>n<sp/>-<sp/>1<sp/>);i<sp/>&gt;=<sp/>0;i--<sp/>)<sp/>{</highlight></codeline>
<codeline lineno="132"><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">if</highlight><highlight class="normal"><sp/>(<sp/><ref refid="classmprod_1cc85192d8abc01832937ed8b62e363a6" kindref="member" tooltip="Indeces of rvc in common rvc.">rvcinds</ref><sp/>(<sp/>i<sp/>).length()<sp/>&gt;<sp/>0<sp/>)<sp/>{</highlight></codeline>
<codeline lineno="133"><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/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>condi<sp/>=<sp/>zeros<sp/>(<sp/><ref refid="classmprod_11725c7b497a27ab3c4889b846666b516" kindref="member" tooltip="Indeces of rvc in common rv.">rvcinrv</ref>.length()<sp/>+<sp/><ref refid="classmprod_1cc85192d8abc01832937ed8b62e363a6" kindref="member" tooltip="Indeces of rvc in common rvc.">rvcinds</ref>.length()<sp/>);</highlight></codeline>
<codeline lineno="134"><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/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">//<sp/>copy<sp/>data<sp/>in<sp/>condition</highlight><highlight class="normal"></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/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>set_subvector<sp/>(<sp/>condi,<ref refid="classmprod_1cc85192d8abc01832937ed8b62e363a6" kindref="member" tooltip="Indeces of rvc in common rvc.">rvcinds</ref><sp/>(<sp/>i<sp/>),<sp/>cond<sp/>);</highlight></codeline>
<codeline lineno="136"><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/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">//<sp/>copy<sp/>data<sp/>in<sp/>already<sp/>generated<sp/>sample</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="137"><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/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>set_subvector<sp/>(<sp/>condi,<ref refid="classmprod_11725c7b497a27ab3c4889b846666b516" kindref="member" tooltip="Indeces of rvc in common rv.">rvcinrv</ref><sp/>(<sp/>i<sp/>),<sp/>smp<sp/>);</highlight></codeline>
<codeline lineno="138"><highlight class="normal"></highlight></codeline>
<codeline lineno="139"><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/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>mpdfs<sp/>(<sp/>i<sp/>)-&gt;condition<sp/>(<sp/>condi<sp/>);</highlight></codeline>
<codeline lineno="140"><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></codeline>
<codeline lineno="141"><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/>copy<sp/>contribution<sp/>of<sp/>this<sp/>pdf<sp/>into<sp/>smp</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="142"><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/>set_subvector<sp/>(<sp/>smp,<ref refid="classmprod_1c8f78fbcdb4e38ecd3197d2958082497" kindref="member" tooltip="Indeces of rvs in common rv.">rvinds</ref><sp/>(<sp/>i<sp/>),<sp/>epdfs<sp/>(<sp/>i<sp/>)-&gt;sample()<sp/>);</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></codeline>
<codeline lineno="144"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>smp;</highlight></codeline>
<codeline lineno="145"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="146"><highlight class="normal"></highlight><highlight class="comment">//<sp/><sp/><sp/><sp/><sp/><sp/>vec<sp/>mean()<sp/>const<sp/>{</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="147"><highlight class="normal"></highlight><highlight class="comment">//<sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>vec<sp/>tmp<sp/>(<sp/>rv.count()<sp/>);</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="148"><highlight class="normal"></highlight><highlight class="comment">//<sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>if<sp/>(<sp/>independent<sp/>)<sp/>{</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="149"><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/>for<sp/>(<sp/>int<sp/>i=0;i&lt;n;i++<sp/>)<sp/>{</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="150"><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/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>vec<sp/>pom<sp/>=<sp/>epdfs<sp/>(<sp/>i<sp/>)-&gt;mean();</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="151"><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/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>set_subvector<sp/>(<sp/>tmp,rvinds<sp/>(<sp/>i<sp/>),<sp/>pom<sp/>);</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="152"><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/>}</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="153"><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="154"><highlight class="normal"></highlight><highlight class="comment">//<sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>else<sp/>{</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="155"><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/>int<sp/>N=50*rv.count();</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="156"><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/>it_warning<sp/>(<sp/>&quot;eprod.mean()<sp/>computed<sp/>by<sp/>sampling&quot;<sp/>);</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="157"><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/>tmp<sp/>=<sp/>zeros<sp/>(<sp/>rv.count()<sp/>);</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="158"><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/>for<sp/>(<sp/>int<sp/>i=0;i&lt;N;i++<sp/>)<sp/>{<sp/>tmp<sp/>+=<sp/>sample();}</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="159"><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/>tmp<sp/>/=N;</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="160"><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="161"><highlight class="normal"></highlight><highlight class="comment">//<sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>return<sp/>tmp;</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="162"><highlight class="normal"></highlight><highlight class="comment">//<sp/><sp/><sp/><sp/><sp/><sp/>}</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="163"><highlight class="normal"></highlight></codeline>
<codeline lineno="164"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>~<ref refid="classmprod" kindref="compound" tooltip="Chain rule decomposition of epdf.">mprod</ref>()<sp/>{};</highlight></codeline>
<codeline lineno="165"><highlight class="normal">};</highlight></codeline>
<codeline lineno="166"><highlight class="normal"></highlight></codeline>
<codeline lineno="170" refid="classmmix" refkind="compound"><highlight class="keyword">class<sp/></highlight><highlight class="normal"><ref refid="classmmix" kindref="compound" tooltip="Mixture of mpdfs with constant weights, all mpdfs are of equal type.">mmix</ref><sp/>:<sp/></highlight><highlight class="keyword">public</highlight><highlight class="normal"><sp/><ref refid="classmpdf" kindref="compound" tooltip="Conditional probability density, e.g. modeling some dependencies.">mpdf</ref><sp/>{</highlight></codeline>
<codeline lineno="171"><highlight class="normal"></highlight><highlight class="keyword">protected</highlight><highlight class="normal">:</highlight></codeline>
<codeline lineno="173" refid="classmmix_1460632c7a0afd41b7840902181a7d85f" refkind="member"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>Array&lt;mpdf*&gt;<sp/><ref refid="classmmix_1460632c7a0afd41b7840902181a7d85f" kindref="member" tooltip="Component (epdfs).">Coms</ref>;</highlight></codeline>
<codeline lineno="175" refid="classmmix_1507a5e6df53e6e9a6a330f1271cf0914" refkind="member"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="classemix" kindref="compound" tooltip="Mixture of epdfs.">emix</ref><sp/><ref refid="classmmix_1507a5e6df53e6e9a6a330f1271cf0914" kindref="member" tooltip="Internal epdf.">Epdf</ref>;</highlight></codeline>
<codeline lineno="176"><highlight class="normal"></highlight><highlight class="keyword">public</highlight><highlight class="normal">:</highlight></codeline>
<codeline lineno="178" refid="classmmix_16769a962f1f4d0ecc5b903b5f7d26ad3" refkind="member"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="classmmix_16769a962f1f4d0ecc5b903b5f7d26ad3" kindref="member" tooltip="Default constructor.">mmix</ref><sp/>(<sp/><ref refid="classRV" kindref="compound" tooltip="Class representing variables, most often random variables.">RV</ref><sp/>&amp;<ref refid="classmpdf_1f6687c07ff07d47812dd565368ca59eb" kindref="member" tooltip="modeled random variable">rv</ref>,<sp/><ref refid="classRV" kindref="compound" tooltip="Class representing variables, most often random variables.">RV</ref><sp/>&amp;<ref refid="classmpdf_1acb7dda792b3cd5576f39fa3129abbab" kindref="member" tooltip="random variable in condition">rvc</ref><sp/>)<sp/>:<sp/><ref refid="classmpdf" kindref="compound" tooltip="Conditional probability density, e.g. modeling some dependencies.">mpdf</ref><sp/>(<sp/>rv,<sp/>rvc<sp/>),<sp/><ref refid="classmmix_1507a5e6df53e6e9a6a330f1271cf0914" kindref="member" tooltip="Internal epdf.">Epdf</ref><sp/>(<sp/>rv<sp/>)<sp/>{<ref refid="classmpdf_17aa894208a32f3487827df6d5054424c" kindref="member" tooltip="pointer to internal epdf">ep</ref><sp/>=<sp/>&amp;<ref refid="classmmix_1507a5e6df53e6e9a6a330f1271cf0914" kindref="member" tooltip="Internal epdf.">Epdf</ref>;};</highlight></codeline>
<codeline lineno="180" refid="classmmix_1e7681490a5c5b2d0a43f4e5842e10a9d" refkind="member"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordtype">void</highlight><highlight class="normal"><sp/><ref refid="classmmix_1e7681490a5c5b2d0a43f4e5842e10a9d" kindref="member" tooltip="Set weights w and components R.">set_parameters</ref><sp/>(<sp/></highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/>vec<sp/>&amp;w,<sp/></highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/>Array&lt;mpdf*&gt;<sp/>&amp;<ref refid="classmmix_1460632c7a0afd41b7840902181a7d85f" kindref="member" tooltip="Component (epdfs).">Coms</ref><sp/>)<sp/>{</highlight></codeline>
<codeline lineno="181"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>Array&lt;epdf*&gt;<sp/>Eps<sp/>(<sp/>Coms.length()<sp/>);</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/></highlight><highlight class="keywordflow">for</highlight><highlight class="normal"><sp/>(<sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>i<sp/>=<sp/>0;i<sp/>&lt;<sp/>Coms.length();i++<sp/>)<sp/>{</highlight></codeline>
<codeline lineno="184"><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/>Eps<sp/>(<sp/>i<sp/>)<sp/>=<sp/>&amp;<sp/>(<sp/><ref refid="classmmix_1460632c7a0afd41b7840902181a7d85f" kindref="member" tooltip="Component (epdfs).">Coms</ref><sp/>(<sp/>i<sp/>)-&gt;_epdf()<sp/>);</highlight></codeline>
<codeline lineno="185"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="186"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="classmmix_1507a5e6df53e6e9a6a330f1271cf0914" kindref="member" tooltip="Internal epdf.">Epdf</ref>.<ref refid="classemix_16ce82b24d7fe540ddbf44b472a005555" kindref="member" tooltip="Set weights w and components R.">set_parameters</ref><sp/>(<sp/>w,<sp/>Eps<sp/>);</highlight></codeline>
<codeline lineno="187"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>};</highlight></codeline>
<codeline lineno="188"><highlight class="normal"></highlight></codeline>
<codeline lineno="189" refid="classmmix_11a66629ec5c2b6f4740606cf737f0193" refkind="member"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordtype">void</highlight><highlight class="normal"><sp/><ref refid="classmmix_11a66629ec5c2b6f4740606cf737f0193" kindref="member" tooltip="Update ep so that it represents this mpdf conditioned on rvc = cond.">condition</ref><sp/>(<sp/></highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/>vec<sp/>&amp;cond<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">for</highlight><highlight class="normal"><sp/>(<sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>i<sp/>=<sp/>0;i<sp/>&lt;<sp/><ref refid="classmmix_1460632c7a0afd41b7840902181a7d85f" kindref="member" tooltip="Component (epdfs).">Coms</ref>.length();i++<sp/>)<sp/>{<ref refid="classmmix_1460632c7a0afd41b7840902181a7d85f" kindref="member" tooltip="Component (epdfs).">Coms</ref><sp/>(<sp/>i<sp/>)-&gt;condition<sp/>(<sp/>cond<sp/>);}</highlight></codeline>
<codeline lineno="191"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>};</highlight></codeline>
<codeline lineno="192"><highlight class="normal">};</highlight></codeline>
<codeline lineno="193"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/>//MX_H</highlight></codeline>
    </programlisting>
    <location file="/home/smidl/work/git/mixpp/bdm/stat/emix.h"/>
  </compounddef>
</doxygen>
