Algorithm works with theta less than 1. The only problem here is that theta can not be 1, because of next line of code

cell->alpha = 1. / (1 - theta);

That’s why I put such restriction. Now I see 2 possible solutions for that:
1) Exclude 1, and allow everything in range (0;+∞).


2) Or just increase/decrease theta by very small number if it is 1.

Nope, this seems quite arbitrary.

I've executed scripts that you attached with different theta and number of outcomes(not n, n remains the same = 100) and I found out that for theta = 0.1 and big number of outcomes it gives distribution very similar to zipfian(for number of outcomes = 100 000, bias -6% to 8% in whole range and for NOO = 1000 000, bias is -2% to 2%).

Ok, so you did not get the large bias for i=3. Strange.

By, number of outcomes(NOO) I mean how many times random_zipfian was called. For example: pgbench -f compte_bench.sql -t 100000 So, I think it works but works worse for small number of outcomes. And also we need to find optimal theta for better results.

Hmmm. I've run one million outcomes each time.

I'll check on the next version.

Sent via pgsql-hackers mailing list (
To make changes to your subscription:

Reply via email to