root/bdm/stat/emix.cpp @ 124

Revision 124, 501 bytes (checked in by smidl, 16 years ago)

zmeny v mmix

  • Property svn:eol-style set to native
Line 
1#include "emix.h"
2
3using namespace itpp;
4
5void emix::set_parameters ( const vec &w0, const Array<epdf*> &Coms0 ) {
6        w = w0;
7        int i;
8        for ( i=0;i<w.length();i++ ) {
9                epdf* Mp=Coms0 ( i );
10                it_assert_debug ( rv.equal ( Coms0 ( i )->_rv() ),"RVs do not match!" );
11        }
12        Coms = Coms0;
13}
14
15vec emix::sample() const {
16        //Sample which component
17        vec cumDist = cumsum ( w );
18        double u0 = UniRNG.sample();
19
20        int i=0;
21        while ( ( w ( i ) <u0 ) && ( i< ( w.length()-1 ) ) ) {i++;}
22
23        return Coms ( i )->sample();
24}
Note: See TracBrowser for help on using the browser.