If I understand, you want to pull a sample from your collection. If there are 1000 records, you'd want a random selection of 100 records (N = 10). If there are 100000 records, you'd want a random selection of 100 records also (N = 1000) ?
I think the Random Attribute approach from the cookbook is the best place to get started:
Once you figure out what N is, which should be something like
var numberOfSamples = 100;
var n = db.x.count() / numberOfSamples;
you can do something like:
var rand = Math.random();
var found = db.x.find({random: { $gte: rand}}).limit(numberOfSamples).toArray();
if (found.length < numberOfSamples) {
var alsoFound = db.x.find({random: { $lte: rand}}).limit(numberOfSamples - found.length).toArray();
//merge alsoFound into found
}