How do I generate numbers according to zipf's law in C++?

60 Views Asked by At

For an array arrayType arrayName[size] = . . ., I want a function arrayType sample() { . . . } to return items from arrayName according to zipf's law (item in position n should have a frequency of m/n where m is the frequency of the first and most common item). I'm not even sure where to start, and I've found similar questions, but only with more specific cases.

I've tried simple searching, precision searching, forum trolling in various places, YouTube videos, and Quora but all to no avail, so I'm here. Any help would be appreciated!

0

There are 0 best solutions below