Mercurial > hg > audiodb
diff sample.cpp @ 284:cacad987d785
Really finish with the sampling branch, this time merging all of it,
yes, even the last revision. (The last revision was one that seeded the
RNG with the current time, which is helpful when trying to get multiple
independent-ish samples from the same database...)
author | mas01cr |
---|---|
date | Mon, 07 Jul 2008 08:57:06 +0000 |
parents | 0e44de38d675 |
children | b9eff6896943 |
line wrap: on
line diff
--- a/sample.cpp Thu Jul 03 08:50:57 2008 +0000 +++ b/sample.cpp Mon Jul 07 08:57:06 2008 +0000 @@ -36,7 +36,7 @@ return c; } -unsigned audioDB::random_track(unsigned *propTable, unsigned total, gsl_rng *rng) { +unsigned audioDB::random_track(unsigned *propTable, unsigned total) { /* FIXME: make this O(1) by using the alias-rejection method, or some other sensible method of sampling from a discrete distribution. */ @@ -57,18 +57,6 @@ void audioDB::sample(const char *dbName) { initTables(dbName, 0); - gsl_rng *rng = gsl_rng_alloc(gsl_rng_mt19937); - - /* FIXME: in Real Life we'll want to initialize the RNG using - /dev/random or the current time or something, like this: - - unsigned int seed; - int fd = open("/dev/urandom", O_RDONLY); - read(fd, &seed, 4); - - gsl_rng_set(rng, seed); - */ - // build track offset table (FIXME: cut'n'pasted from query.cpp) off_t *trackOffsetTable = new off_t[dbH->numFiles]; unsigned cumTrack=0; @@ -105,8 +93,8 @@ double sumlogdist = 0; for (unsigned int i = 0; i < nsamples;) { - unsigned track1 = random_track(propTable, total, rng); - unsigned track2 = random_track(propTable, total, rng); + unsigned track1 = random_track(propTable, total); + unsigned track2 = random_track(propTable, total); if(track1 == track2) continue;