How can I simulate the gaussian distribution

Hi ,

How can I simulate the gaussian distribution (normal distribution in Qspice). I came accross this post while searching the method
Simulating tran noise with QSPICE - QSPICE - Qorvo Tech Forum

I have plotted the histogram of the method in the post. However, it does not look like the normal distribution to me.


PyQSPICE


Here is how you simulate gaussuan distribution.



Best regards

Hi Ivan,

Thank you for the solution. Is there any way I can do it in the transient analysis? I want to see how my circuit react to noise.

Regards,
Joe

(post deleted by author)

This is a workaround, by adding 6 random calls to make gaussian look alike distribution.

V=random(time)-random(time+17)+random(time+27)-random(time+37)+random(time+47)-random(time+57)


This is the best I can think of in generating a gaussian distribution in .tran and can follow gaussian distribution in regardless simulation time.

SrcGaussian.qsym (2.2 KB)
example.SrcGaussian.qsch (3.2 KB)

** if you enable .option seedclock, it can generate new set of random number in each simulation run.

Here is netlist of this .subckt for your reference

.subckt X1•SrcGaussian Y0+ Y0- Y1+ Y1-
B1 U1 0 V=limit(random(1e15*time/V(divider)+1e15*random()),1m,0.999)
B2 U2 0 V=limit(random(1e15*time/V(divider)+1e15*random()),1m,0.999)
B3 Z0 0 V=sqrt(-2.0*log(V(U1)))*cos(2.0*3.14159*V(U2))
B4 Z1 0 V=sqrt(-2.0*log(V(U1)))*sin(2.0*3.14159*V(U2))
B5 Y0+ Y0- V=mean + std * V(Z0)
B6 Y1+ Y1- V=mean + std * V(Z1)
B7 divider 0 V=pow(10,floor(log10(time)))
.ends SrcGaussian