I want to obtain a random number from a truncated normalized distribution. Let's say that we have the following:
Now, imagine that we want to obtain the aforementioned random number from a truncated normalized distribution such that its mean value will be equal to magnetization, and its standard deviation will be given by, for example, sigma=1. I have seen that I can create my distribution easily from https://es.mathworks.com/help/stats/prob.normaldistribution.truncate.html. But how can I extract from here a random number [magnetization-0.03*magnetization, magnetization+0.03*magnetization] according to this distribution in which not all numbers are equally probable?
But note that the random numbers are almost uniformly distributed. This is because the untruncated normal is pretty flat in the narrow region where you are truncating. If you reduce the pretruncSD to (say) 0.03, the generated random numbers will look much more like a normal with the tails chopped off.