Crop a normal distribution to a predefined uniform distribution

5 visualizaciones (últimos 30 días)
Hello,
I generate three normal distributions (image 1). I want to select the generated values within a chosen range in each distribution (red boxes) so that these values will make up 3 uniform distributions. This is different from generating 3 uniform distributions in the first place because the values have already existed. My current solution is to crop the distributions to the desired range, then use randsample. However, the result is still not uniform (image 2). Can someone please help?
distribution.jpg
crop.jpg

Respuesta aceptada

Jeff Miller
Jeff Miller el 29 de Mayo de 2019
Maybe:
  1. Choose an interval randomly (e.g., the middle distribution in your original figure seems to have about 14 intervals ranging from about 5.7 to 7.5), such that all intervals have equal probability.
  2. Choose one of the points within the chosen interval randomly, such that all points within the interval have equal probability.

Más respuestas (2)

John D'Errico
John D'Errico el 28 de Mayo de 2019
This does not make sense. You have a data that lives in a roughly normal distribution, although it seems corrupted, if I look at the histograms. I think that means your data is actually discrete, and not truly continuous, so the histograms look like they have spikes in them.
Now, you want to use that data, apparently sampling from the data itself. But you want it to be cropped, so you toss out all of the stuff outside of some chosen ranges. Fine.
But finally, you then want to change the distribution into a uniform one over that interval? Huh?
Why not just sample from a uniform distribution over the desired interval? Sorry, but this is making no sense. Conversely, it is making nonsense.
It seems you have two options, both of which start by sampling from a uniform distribution living on the desired intervals. You now have a nicely uniform sample. If you don't know how to sample from a uniform distribution over some given interval [a,b], then read the help for rand.
Finally, choose option 1 or 2:
  1. Quantize the uniform samples to be quantized similarly to the original data. This is probably just a call to round, at some number of digits. If the quantization interval is not a power of 10, then divide by the quantization interval, round the numbers, then multiply by the quantization interval.
  2. For any sample from the uniform, just find the closest point in your random set. Use that instead.
In either case, you will have a sample that is as uniform as possible, subject to the desired goals. Why you want to do this? God only knows.

Tram Nguyen
Tram Nguyen el 28 de Mayo de 2019
Editada: Tram Nguyen el 28 de Mayo de 2019
Hi John,
Thank you for your answer and pardon me for my weak math background. I know it's an unusual question, it's actually for a very specific problem I'm having. Anyway, let me try to explain it more clearly.
I want to generate 300 arrays, each has 12 discrete numbers from 1 to 12 with a predefined mean and variance. Of these 300 arrays, 100 needs to have a low-range actual mean (1.5 to 3.5), 100 of medium-range mean (5.5 to 7.5), and 100 of high-range mean (9.5 to 11.5). I can do this using rand. What I want to achieve is a uniform distribution of low-range means, medium-range means, and high-range means.
So what I did in image 1 is generate 10000 arrays, mean of which are of these 3 ranges (image 1 is the histogram of these means). Then I try to extract 300 out of them to keep them uniform. Perhaps you could offer a better solution for my problem?
Also I'm not understanding your option 1. Can you give me an example?
Thanks!

Productos


Versión

R2018b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by