Say I have X or 3 sets of different sizes.
So 3×4×5
I want to generate a probability distribution of the Cartesian of these sets that eventually and is guaranteed to cover every item.
Which based on my other answer I can generate the Nth Cartesian product by
items = []
N = self.N
for item in sets:
N, r = divmod(N, len(item))
items.append(item[r])
self.N = self.N + 1
Now I want to bias the distribution of the set to be unfair.
For example, If I have three sets a, b and c. I want to pick an item from a more often than b and an item of b more often than c but I want all items to eventually occur.
One inefficient idea I have is to generate all the indexed of every Nth position and order them based on a distribution but I am not sure how to do that.
Why am I trying to do this? I am trying to schedule things.
I think I found a solution. It's also incremental and small change. We introduce a frequency array. This is the priority order. 0 means that this column shall grow the least, then 1 means this column shall grow the most. 2 means that this column shall grow more than 0 but less than 1. I'm not sure why.
Here's the output: