Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What is this algorithm? #123

Closed
jc211 opened this issue Feb 9, 2022 · 1 comment
Closed

What is this algorithm? #123

jc211 opened this issue Feb 9, 2022 · 1 comment

Comments

@jc211
Copy link
Contributor

jc211 commented Feb 9, 2022

Below looks like some kind of pseudo random number generator. Any reference to the algorithm used here?

idx = ((i+step*n_elements) * 56924617 + j * 19349663 + 96925573) % (NERF_GRIDSIZE()*NERF_GRIDSIZE()*NERF_GRIDSIZE());

@Tom94
Copy link
Collaborator

Tom94 commented Feb 9, 2022

It's a linear congruential generator, which is a form of pseudo-random number generator. Its statistical properties are somewhat bad, but it is very efficient.

Here, we don't actually care much about its statistical properties. Rather, we care about its property of producing a permutation: this use case distributes the density grid update samples more-or-less uniformly over space (due to the pseudo-random nature), but ensures good coverage by never visiting a grid cell twice without having visited all other cells (due to the permutation property).

Feel free to re-open the issue if something is still unclear!

@Tom94 Tom94 closed this as completed Feb 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants