Questions tagged [non-uniform-distribution]
24 questions
43
votes
10 answers
Java: random integer with non-uniform distribution
How can I create a random integer n in Java, between 1 and k with a "linear descending distribution", i.e. 1 is most likely, 2 is less likely, 3 less likely, ..., k least likely, and the probabilities descend linearly, like this:
I know that there…

Leo
- 772
- 1
- 6
- 15
17
votes
2 answers
Effective Java Item 47: Know and use your libraries - Flawed random integer method example
In the example Josh gives of the flawed random method that generates a positive random number with a given upper bound n, I don't understand the two of the flaws he states.
The method from the book is:
private static final Random rnd = new…

Derek Mok
- 253
- 1
- 7
10
votes
5 answers
Implementing Box-Mueller random number generator in C#
From this question: Random number generator which gravitates numbers to any given number in range? I did some research since I've come across such a random number generator before. All I remember was the name "Mueller", so I guess I found it,…

Lasse V. Karlsen
- 380,855
- 102
- 628
- 825
7
votes
3 answers
Random non-uniform distribution with given proportion
I have 3 labels: "A","B","C".
I want to generate a random list with 100 elements, 60% of them are "A", 30% are "B", 10% are "C".
How can I do this? (I am new in python, hope this question is not too silly.)
Edit:
My question is slightly different…

xirururu
- 5,028
- 9
- 35
- 64
6
votes
2 answers
Fourier transform in 3 dimensions on a non uniform grid in matlab
I need to calculated a 3D Fourier transform of a structures I have their [x,y,z] coordinates. I thought of interpolating to a uniform grid of the smallest spacing between the points and use fft, but that turned to be impractical in memory, so fft…
user2066183
5
votes
1 answer
Non-uniform Distributions for Haskell data types
The random package contains a type class Uniform for uniformly distributed types.
This works for types like:
data Coin = Heads | Tails
But let's say I want to model a set of things with a non-uniform distribution, for example by adding the…

theo
- 305
- 2
- 7
5
votes
3 answers
equivalent function to numpy.random.choice in C++
I need your help to solve the following problem:
Is there a function in c++/opencv which is equivalent to the following code:
np.random.choice(len(vec), samples, p=probabilities[:,0], replace=True)
Thanks in advance.

jack
- 195
- 1
- 2
- 11
4
votes
3 answers
2D Interpolation irregular grid fortran
How can I implement 2-dimensional interpolation in FORTRAN where the data looks like as shown below.
x and y are two co ordinates and z is a value dependent on them
x is spaced evenly but y is not uniformly spaced and the maximum value of…

user1117812
- 121
- 2
- 7
3
votes
2 answers
Fill a vector with a specific distribution of nonuniform screen points
I am trying to fill a vector with a specific distribution of nonuniform screen points. These points represent some x and y position on the screen. At some point I am going to draw all of these points on the screen, which should be unevenly…

Spicy Currey
- 31
- 3
2
votes
4 answers
Random numbers with non-uniform discrete densities
Just wondering what type of algorithm this is,
or if there is an easier/more efficient way to go about this:
Say we are given a certain probability density, say
prob[] = {.1, .15, .25, .05, .45}
Group 1 - 10%
Group 2 - 15%
Group 3 - 25%
Group 4 -…

Jared
- 65
- 10
2
votes
2 answers
Bicubic Interpolation for Non-regular grids?
I am working on a project where I have a set of known measurements (x,y,z,a) and an input (z,a). I need to be able to interpolate the (x,y,z) so that I can get a list of possible (x,y) coordinates from a given z.
I was looking at bicubic…

FlyingStreudel
- 4,434
- 4
- 33
- 55
2
votes
1 answer
Why does taking the salted hash of the mod of a hash result in a very non-uniform distribution?
I have a million randomly generated unique IDs.
If I do:
result = int(hash(id + 'some_salt')) % 1000
Then this seems to result in an even distribution of IDs to some integer between 0 and 999, with each integer having approximately 1000 IDs mapped…

Josh
- 697
- 6
- 21
1
vote
1 answer
How to adjust for non-uniform sampling (log-scale/polar) in Monte Carlo integration?
I am trying to perform Monte Carlo integration of a function, but sample non-uniformly. I need this method to work for both logarithmic scale and for integration in polar coordinates since I will then combine the two and use polar with log-scale…

Marek Matas
- 13
- 3
1
vote
0 answers
Do the non-uniform distribution scores reduce Redis Sorted Set performance?
I wonder whether the non-uniform distribution scores would reduce Redis Sorted Set performance.
There are two random score generation functions, one obeys uniform distribution, and the other obeys a special custom distribution as the following…

da_miao_zi
- 351
- 1
- 11
1
vote
0 answers
Create equally spaced data from sensor data to apply Fast Fourier Transform
I have the following sensor sample data:
Time(milliseconds) Data
------------------ -------------------
0 0.30865225195884705
60 0.14355185627937317
100 -0.16846869885921478…

danishjo
- 159
- 1
- 1
- 8