Hello, I try to run the monte Carlo simulation, but I saw nowhere in the documentation related topics, so I tried to do it myself. For that I searched a random number generator function and the only clue I could find is on .option seed part. There on note 7 tells very little about the gauss() and random() functions. I tried to make it run with usual .step dummy 0 250 1, but I saw that the values of my voltage source, don’t change from simulation to simulation, and neither they are more than 9.

My question is. How can I increase the number of generated numbers? How I can tell to simulator to regenerate it on each simulation?

Thank you!

Below would be the idea. This is one time curly braces would be recommended to enforce evaluation of random() by the preparser, and not by the random(x) function available during a simulation, the later being useful for generating things like a random bit stream.

I think the random() function should be rather indistinguishable from a true random sequence. It’s based on a Mersenne twister.

Mike,

I could be wrong about my interpretation of @Andru 's post.

I think he is asking for a “true random number generator”. The random() function works with a seed value. If I change the seed, I get a different starting point in the stepped sequence. (ie. .option SEED=4)

However, if the seed is the same between sim runs, it yields the same random() at each step between sims.

Is there a way to generate a “new” seed at the beginning of the sim?

For example in ‘C’ code, I have used the ‘low’ current time value (msec value) as the seed at the time of starting the application.

Len

@Engelhardt Ipoma interpretated Andru’s post as request of different seed at every run. In LTspice, there is an option to enable “Use the clock to reseed the MC generator” to generate different seed between run. Does Qspice has this feature?

In the meantime I found ways of generating with random() and with gauss() functions some kind of Monte Carlo points that I can plot it after with excel. But the problem persisted when rerunning the simulation, as the guys already explained. I just want to ask, is there a way/function that will generate new seed after a simulation restart, or it will be added a feature that we have to enable it in the future? Plus, in current state does save some calculating power/time by outsourcing the same points when the simulation is restarted? Thanks

OK, I just implemented

.options seedclock

It convolutes a 10MHz system clock with the simulation process ID to generate a physically random integer to seed the Mersenne Twister.