protected function drawIndex(array $d)
     {
         $x = $this->mt->generate();
         $p = 0.0;
         foreach ($d as $i=>$v) {
             $p+=$v;
             if ($p > $x)
                return $i;
         }
     }
protected function drawIndex(array $d)
     {
         $x = $this->mt->generate();
         $p = 0.0;
         foreach ($d as $i=>$v) {
             $p+=$v;
             if ($p > $x)
                return $i;
         }
     }
protected function drawIndex ( array $ d ) { $ x = $ this -> mt -> generate ( ) ; $ p = 0.0 ; foreach ( $ d as $ i => $ v ) { $ p += $ v ; if ( $ p > $ x ) return $ i ; } }
Draw once from a multinomial distribution and return the index
of that is drawn.

@return int The index that was drawn.
Draw once from a multinomial distribution and return the index of that is drawn .