Using gnoise to create a distribution with bounded values?

Hi there,

I'm trying to do a bit of modeling where I want to make a set of Gaussians built using random values for the positions, widths, and amplitudes. The part that is giving me issues is that the amplitudes must have values between 0 and 1 while the widths need to be larger than 0. I started using the code below, but I think that I need to use a truncated distribution to accomplish what I want (https://en.wikipedia.org/wiki/Truncated_normal_distribution). Any suggestions on how to approach this? Thanks!

Function randomGen(posSTD,gPos,widSTD,gWid,ampSTD,gAmp,nTrials)
   
    Variable posSTD //What's the standard deviation of the Gaussian positions?
    Variable gPos //What's the position of the Gaussian?
    Variable widSTD //What's the standard deviation of the Gaussian widths?
    Variable gWid //What's the width of the Gaussian?
    Variable ampSTD //What's the standard deviation of the Gaussian amplitudes?
    Variable gAmp   //What's the amplitude of the Gaussian?
    Variable nTrials    //How many trials to use to construct noise wave?

    Make/o/n=(nTrials) gnoisePosWave,gnoiseWidWave,gnoiseAmpWave,cdf,pdf
    gnoisePosWave = gnoise(posSTD) + gPos   //Make gaussian noise centered at gPos w/ STD= gaussSTD
    gnoiseWidWave = gnoise(widSTD) + gWid
    gnoiseAmpWave = gnoise(ampSTD) + gAmp
End

Function truncatedGNoise(Variable sigma, Variable mean, Variable minvalue, Variable maxvalue)
    Variable returnval
    do
        returnval = gnoise(sigma)+mean
    while (returnval < minvalue || returnval > maxvalue)
   
    return returnval
end

On the other hand, perhaps you need a different distribution?

The attached graph was made with

make/n=1000 junk
•junk=truncatedGNoise(3,3,0,10)
Make/N=20/O junk_Hist;DelayUpdate
Histogram/B=1 junk,junk_Hist

 

TruncatedGaussian.png