Skip to content

Instantly share code, notes, and snippets.

@craigphicks
Last active February 11, 2025 01:49
Show Gist options
  • Save craigphicks/c8cd362dcded53124aa6e78c76a79816 to your computer and use it in GitHub Desktop.
Save craigphicks/c8cd362dcded53124aa6e78c76a79816 to your computer and use it in GitHub Desktop.
Output of decision rules table code example

Correspondence between m and PyTorch call form

m call
24 argsort(rand((batch_count,K)))
32 argsort(randint(low=-2**31,high=2**31-1,(batch_count,K),dtype=integer32))
64 argsort(randint(low=-2**63,high=2**63-1,(batch_count,K),dtype=integer64))



Example 1:

Call Validities for log2(K)=15.0000, P_crit=0.55, log2(N)=0.0000

m valid max allowed log2(K)
24 15.3384
32 20.6717
64 42.0051

Given parameters P_crit=0.55 and N=1 a length 32768 permutation is allowed for any bit count random number.



Example 2:

Call Validities for log2(K)=15.0000, P_crit=0.55, log2(N)=16.0000

m valid max allowed log2(K)
24 10.0051
32 15.3384
64 36.6717

Given parameters P_crit=0.55 and N=65536 a length 32768 permutation is not allowed for bit count 24, but is allowed for bit counts 32 and 64 random numbers.



Example 3. Explore the limits of using randint with 64 bits:

Call Validities for log2(K)=25.0000, P_crit=0.55, log2(N)=26.0000*

m valid max allowed log2(K)
24 6.6717
32 12.0051
64 33.3384

Call Validities for log2(K)=25.0000, P_crit=0.50001, log2(N)=26.0000

m valid max allowed log2(K)
24 -1.5226
32 3.8107
64 25.1441

Call Validities for log2(K)=25.0000, P_crit=0.500001, log2(N)=26.0000

m valid max allowed log2(K)
24 -3.7372
32 1.5961
64 22.9295

It is evident that used 64-bit random numbers will produce unbiased result for all but the most extreme cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment