# Monte carlo analysis with random() and gauss()

### Dear community,

as I was struggling with this a bit in the beginning, sharing this might help someone. Goal was to model a output voltage spread of an LDO varying the Vref=0.55V (1.5% tolerance) and divider resistors (1% tolerance).

I was interested how the results differ when using “random()” function or “gauss()” function. In the case of gauss() the argument is sigma and the percentage of tolerance is considered as 6sigma. Therefore the argument is (tol/600).

### The typical Vout value (no component variation) is Vout=1.275V

I also used Python scipt (credit: PyLTSpice · PyPI) to create the histograms.The visual difference between the results is apparent

### Histogram of V(out_gauss)

Hereby I’d like to suggest to Mike @Engelhardt making the .meas output more machine-processing friendly. I needed to do some manual editing after every simulation to be able to process with python script. Option of some basic .csv- type output would be greatly appreciated.

Kind regards,
Tomas

From your implementation, it appears that you may not be aware that Mike has implemented functions that could simplify your formula. Some of these functions may be undocumented, but you can find their implementation in the revision history.

• Random() : Random value between 0 and 1, uniform distribution
• Gauss(σ) : Random number from Gaussian distribution with standard derivation σ and mean value at 0
• Flat(x) : Random number between -x and x with uniform distribution
• Mc(x,y) : Random number between x*(1+y) and x*(1-y) with uniform distribution
• GAUSS(Nominal Value, Relative variation, Sigma) [refer to below example]
• AGAUSS(Nominal Value, Absolute variation, Sigma) [refer to below example]

1 Like

Thanks for the hints @KSKelvin !!