Skip to content

Math.random in mode:gpu #498

Description

@marcelloexp386

A GIF or MEME to give some spice of the internet

What is wrong?

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

How do we replicate the issue?

const { GPU } = require('gpu.js');
const gpu = new GPU({ mode: 'gpu' });
const nobs=10000;

const kernel = gpu.createKernel(function() {
const y=Math.random();
return y;
}, { output: [nobs] });
const data = kernel();

How important is this (1-5)?

5

Expected behavior (i.e. solution)

the data should be uniform

Other Comments

Probably, in the plugin you should have chosen nrandom instead of n4random.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions