docs: public int sample()
      {
          double val = this.rand.nextDouble() * this.sum;
          int sample = 0;		
          while(sample < this.likelihoods.length){
              val -= this.likelihoods[sample];
              if(val < 0){
                  return sample;
              }
              
              sample++;			
          }
          
          return this.rand.nextInt(this.likelihoods.length);
      }