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

.tools.CubicInverseTransform is using wrong pRNG. #27

Open
RuiFilipeCampos opened this issue Aug 2, 2021 · 1 comment
Open

.tools.CubicInverseTransform is using wrong pRNG. #27

RuiFilipeCampos opened this issue Aug 2, 2021 · 1 comment
Labels
bug Something isn't working important

Comments

@RuiFilipeCampos
Copy link
Owner

cdef double _sample(self):
self.R = self.N * rand()
self.i = <int> self.R
if self.R - self.i < self.cut_offs[self.i]:
self.dx = rand() * self.DX[self.i]
self.y = self.c[3, self.i]
self.y += self.c[2, self.i]*self.dx
self.dx *= self.dx
self.y += self.c[1, self.i]*self.dx
self.dx *= self.dx
self.y += self.c[0, self.i]*self.dx
return self.y
self.i = self.rej_indexes[self.i]
self.y = self.c[3, self.i]
self.dx = rand()*self.DX[self.i]
self.y += self.c[2, self.i]*self.dx
self.dx *= self.dx
self.y += self.c[1, self.i]*self.dx
self.dx *= self.dx
self.y += self.c[0, self.i]*self.dx
return self.y

Using old pRNG.

@RuiFilipeCampos RuiFilipeCampos changed the title .tools.CubicInverseTransform is using wrong pRNG. [BUG] .tools.CubicInverseTransform is using wrong pRNG. Mar 31, 2022
@RuiFilipeCampos
Copy link
Owner Author

RuiFilipeCampos commented Mar 31, 2022

Currently using rand from std lib.

from libc.stdlib cimport rand, RAND_MAX

I'm inclined to believe that using two completely independent random number generators, using completely different algorithms, generating numbers that essentially do not interact, should not affect the results. Except for the part that the quality of the pRNG in stdlib does not compare to MIXMAX. It likely affects results in this way, but likely not in an catastrophic manner.

Regardless, MontyCarlo simulates billions of particles, so this change is important because stdlib prng will fail.

This change should be done after MVP and only when I decide on the final structure of MontyCarlo, otherwise it's just lost time compiling on a low level matrix from hell.

@RuiFilipeCampos RuiFilipeCampos changed the title [BUG] .tools.CubicInverseTransform is using wrong pRNG. .tools.CubicInverseTransform is using wrong pRNG. Apr 30, 2022
@RuiFilipeCampos RuiFilipeCampos added the bug Something isn't working label Apr 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working important
Projects
None yet
Development

No branches or pull requests

1 participant