
Using gnoise to create a distribution with bounded values?
vmmr5596
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
On the other hand, perhaps you need a different distribution?
The attached graph was made with
August 19, 2020 at 12:01 pm - Permalink
In reply to Function truncatedGNoise… by johnweeks
Thanks John! This is exactly what I needed! Best.
August 19, 2020 at 12:22 pm - Permalink