You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The random number distribution is Normal instead of Uniform[0,1]
Where does it happen?
Ex. In GPU.js when I run Math.random inside a gpu.createKernel(function() in Node.js on my pc windows 10 and Nvidia GPU
NB If mode is set to cpu, all else equal, the numbers are Unifom
Hi Robert, I am quite new to gpu.js and zero-knowledge of WebGL, shaders ... so I think to be quite hopeless in finding a solution. To be totally honest I just had the intuition that the problem was in the choice of n4rand.
In https://www.shadertoy.com/view/4t2SDh, you can find the file generating the noise with the 4 different functions. One can see that nrand produce a uniform histogram, while the others n1rand, n2rand, n3rand and n4 rand produces triangle and bell shaped histograms.
In your plugin triangle-noise.js, you make a functionReplace of Math.random() with n4rand(vTexCoord). If I interpreted correctly your code, the right function should be nrand.
My script for testing the statistical properties of the random numbers is attached here (as I said, I run it with node and one can alternatively select "cpu" or "gpu" in line 10). If you take the data saved in the txt file and plot the histogram you will immediately see the bell shaped curve for the data generated with the "gpu" mode. stampa_randnumbers_GPU_v01.js.txt
Hi Robert, i forgot to tell you if you can send me an email when you have solved the problem.
Yours, Marcello
Ottieni Outlook per Android<https://aka.ms/ghei36>
________________________________
From: Marcello Esposito
Sent: Friday, September 20, 2019 3:05:51 PM
To: gpujs/gpu.js <reply@reply.github.com>; gpujs/gpu.js <gpu.js@noreply.github.com>
Cc: Author <author@noreply.github.com>
Subject: Re: [gpujs/gpu.js] Math.random in mode:gpu (#498)
Hi Robert, i forgot to tell you if you can send me an email when you have solved the problem.
Yours, Marcello
Ottieni Outlook per Android<https://aka.ms/ghei36>
Hi Robert, tremendous improvement! I run a "pi" test (i.e. estimation of the pi value) and now the results do not show anymore the systematic bias. Still, the GPU method produces worse estimates (in the sense of higher stdev) than the CPU method, but this was expected. If, somewhere in your blog, you can mention RandomPower for having contributed to your project, it would be very much appreciated. RandomPower is a university spin-off where we use a quantistic effect of the light in order to generate True Random Numbers .
? In reality, my contribution was just about "testing" your random number generator algorithm. So, I would simply mention randompower.eu among the contributors to the gpujs project.
We can analyze their statistical properties but it will take a bit of time because at the moment we are working on the hardware of our project. As soon as we have a couple of days free, we can come back with some stats.
If/when you put a link to our website somewhere in your blog, let me know.
Activity
robertleeplummerjr commentedon Sep 18, 2019
Do you have a link to that function? It was super difficult to find any insight when implementing.
marcelloexp386 commentedon Sep 18, 2019
Hi Robert, I am quite new to gpu.js and zero-knowledge of WebGL, shaders ... so I think to be quite hopeless in finding a solution. To be totally honest I just had the intuition that the problem was in the choice of n4rand.
In https://www.shadertoy.com/view/4t2SDh, you can find the file generating the noise with the 4 different functions. One can see that nrand produce a uniform histogram, while the others n1rand, n2rand, n3rand and n4 rand produces triangle and bell shaped histograms.
In your plugin triangle-noise.js, you make a functionReplace of Math.random() with n4rand(vTexCoord). If I interpreted correctly your code, the right function should be nrand.
My script for testing the statistical properties of the random numbers is attached here (as I said, I run it with node and one can alternatively select "cpu" or "gpu" in line 10). If you take the data saved in the txt file and plot the histogram you will immediately see the bell shaped curve for the data generated with the "gpu" mode.
stampa_randnumbers_GPU_v01.js.txt
robertleeplummerjr commentedon Sep 18, 2019
Fantastic! Ty for not attacking this, it was quite the thing to figure out. I'll review asap, and get it corrected. Again TY!
marcelloexp386 commentedon Sep 18, 2019
Thanks to you and the gpu team for the fantastic job you are doing with gpu.js!
robertleeplummerjr commentedon Sep 18, 2019
ty for trying it!
marcelloexp386 commentedon Sep 20, 2019
marcelloexp386 commentedon Oct 16, 2019
robertleeplummerjr commentedon Oct 18, 2019
Hi Robert, did you succeed in changing algorithm?>
I tried some changes out this morning on this branch: https://github.com/gpujs/gpu.js/tree/498-uniformly-distributed
Can you take look and see if that is good enough for your needs?
I can see a noticeable improvement when comparing them on the
./examples/random.htmlpage.robertleeplummerjr commentedon Oct 29, 2019
FYI: https://github.com/gpujs/gpu.js/tree/498-uniformly-distributed will be merged soon, and addresses the issue brought up here.
marcelloexp386 commentedon Oct 29, 2019
Hi Robert, tremendous improvement! I run a "pi" test (i.e. estimation of the pi value) and now the results do not show anymore the systematic bias. Still, the GPU method produces worse estimates (in the sense of higher stdev) than the CPU method, but this was expected. If, somewhere in your blog, you can mention RandomPower for having contributed to your project, it would be very much appreciated. RandomPower is a university spin-off where we use a quantistic effect of the light in order to generate True Random Numbers .
robertleeplummerjr commentedon Oct 29, 2019
Do you have a link to RandomPower?
marcelloexp386 commentedon Oct 29, 2019
https://www.randompower.eu/
robertleeplummerjr commentedon Oct 29, 2019
Can you get me more details on the contribution?
marcelloexp386 commentedon Oct 29, 2019
? In reality, my contribution was just about "testing" your random number generator algorithm. So, I would simply mention randompower.eu among the contributors to the gpujs project.
robertleeplummerjr commentedon Oct 29, 2019
Awesome! Is there any sort of qualification that our random generates that we can make mention of?
marcelloexp386 commentedon Oct 29, 2019
We can analyze their statistical properties but it will take a bit of time because at the moment we are working on the hardware of our project. As soon as we have a couple of days free, we can come back with some stats.
If/when you put a link to our website somewhere in your blog, let me know.
robertleeplummerjr commentedon Oct 29, 2019
I'll just put a shout out to RandomPower in the readme if that is ok. That way everyone sees it. Also, I very much look forward to those test results!
fix: Add credit from #498 (comment)
robertleeplummerjr commentedon Oct 29, 2019
Fixed in https://www.npmjs.com/package/gpu.js/v/2.2.0
marcelloexp386 commentedon Oct 29, 2019
fix: Add credit from gpujs#498 (comment)