Vector.random uses the wrong distribution
See original GitHub issueThe (https://github.com/mateogianolio/vectorious/wiki/Vector-API#random)[docs] state that Vector.random
samples based on a normal distribution using the passed mean and standard deviation. What the code actually does is using a uniform distribution, which is not even centered around the passed mean, but around (mean+deviation)/2
.
Here is the code in vector.js:
Vector.random = function (count, deviation, mean, type) {
deviation = deviation || 1;
mean = mean || 0;
return Vector.fill(count, function() {
return deviation * Math.random() + mean;
}, type);
};
(A detail: when 0
is passed as the deviation, it should not be reset to 1
.)
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
8.3: Problems on Random Vectors and Joint Distributions
Exercise 8.3.1. Two cards are selected at random, without replacement, from a standard deck. Let X be the number of aces and Y...
Read more >Fill a vector with random numbers c++ - Stack Overflow
You can use std::generate algorithm to fill a vector of n elements with random numbers. In modern C++ it's recommended not to use...
Read more >Chapter 5. Vector random variables
Vector random variables let us model relationships between quantities. ... The parameters of the bivariate normal distribution in matrix form are.
Read more >Random Vectors - Project Euclid
A random vector X E V(., .) is called orthogonally invariant about x, if. X - x, has an orthogonally invariant distribution. It...
Read more >Construct a random vector as a function of ... - MathOverflow
Much simpler is to verify the existence of a 3-d distribution function that satisfies constraints 1-2 and, then, use the construction I'm ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The pull request was only addressing an incorrect falsy test of the function arguments. The issue I described is still the same: Math.random() picks a number from a uniform distribution in [0,1). The code assumes that it returns a normal distribution centered around 0.
https://arxiv.org/pdf/1303.6257.pdf