Monday, October 8, 2012


Weighted Random Sampling With Replacement 


Select k items from n with replacement, based on weights w[n]. Populate dest from src. Here, k=n


double sum_w = 0.0;
for(i = 0; i < n; ++i) {
  sum_w += w[i];
}

int i, j;

for (j = 0; j < n; ++j){
  double u = random*sum_w;
  for(i = 0; i < n; ++i) {
    u -= w[i];
    if (u < 0) {break;}
  }
  dest[j]=src[i];
}


Monday, April 28, 2008

Stumble Thought

This is a place for inane blabber. Unlike "Thus I spake", where I jot down structured and thought out thoughts or stories, this is gonna be a place for thoughts that spring up into my mind, those which are worth mentioning!

Hope you like this free ride too...