Speeding up calculation time for Monte Carlo simulations

Speeding up calculation time for Monte Carlo simulations - Messages

#1 Posted: 12/1/2023 4:41:02 AM
Fikret Atalay

Fikret Atalay

2 likes in 24 posts.

Group: User

Hi all, I don't even know if this is possible, but I figured I would ask anyways to see if someone might know any tricks.

I wrote a worksheet to show my students an example of a method for making probabilistic calculations of a parameter instead of using deterministic methods. The probabilistic calculation using Monte Carlo simulation lends itself to calculating probability of failure, which is a nice way of explaining system reliability.

Ideally, one would run a large number of simulations so that the result converges. However, it seems like the matrix calculations (or at least the way I am doing them) are quite slow, and when I assign a meaningful number of trials (say, 1000 or more), it takes the worksheet forever to calculate. I can do the same in Excel and it is almost instantaneous to do even 10000 or 20000 trials, but I hate doing these in Excel since I can show the work and the equations much more easily with SMath.

Any suggestions on what might speed up the run-time? The worksheet is attached for reference.

Thanks!
FT

Correlated Normal Variables - Bearing Capacity Example.sm (417 KiB) downloaded 47 time(s).
#2 Posted: 12/1/2023 4:51:42 AM
Martin Kraska

Martin Kraska

1222 likes in 2150 posts.

Group: Moderator

You just have to switch all cells to numeric optimization (Ctrl A to select everything, right mouse button on any cell, select Optimization> Numeric

Then, with 10000 tries it took a couple of seconds on my 6 years old notebook.

Correlated Normal Variables - Bearing Capacity Example_Kr.sm (417 KiB) downloaded 51 time(s).
Martin Kraska Pre-configured portable distribution of SMath Studio: https://en.smath.info/wiki/SMath%20with%20Plugins.ashx
1 users liked this post
sergio 12/1/2023 5:43:00 PM
#3 Posted: 12/1/2023 4:55:34 AM
Fikret Atalay

Fikret Atalay

2 likes in 24 posts.

Group: User

And there it is, easy as that Thank you so much!

Wrote

You just have to switch all cells to numeric optimization (Ctrl A to select everything, right mouse button on any cell, select Optimization> Numeric

Then, with 10000 tries it took a couple of seconds on my 6 years old notebook.

Correlated Normal Variables - Bearing Capacity Example_Kr.sm (417 KiB) downloaded 51 time(s).



1 users liked this post
sergio 12/1/2023 5:43:00 PM
#4 Posted: 12/2/2023 1:35:02 AM
Jean Giraud

Jean Giraud

983 likes in 6866 posts.

Group: User

Wrote

Any suggestions on what might speed up the run-time? The worksheet is attached for reference.


The attached document runs Monte-Carlo in two styles.
1. Logistic style 4 s
2. Ordinary style 0.7 s
Observe eval(,)
Jean

Stat Monte Carlo [rlogis] Copy 2.sm (102 KiB) downloaded 36 time(s).
#5 Posted: 12/2/2023 1:45:46 AM
Fikret Atalay

Fikret Atalay

2 likes in 24 posts.

Group: User

Thanks for sharing, looks like it will be useful!

Wrote

Wrote

Any suggestions on what might speed up the run-time? The worksheet is attached for reference.


The attached document runs Monte-Carlo in two styles.
1. Logistic style 4 s
2. Ordinary style 0.7 s
Observe eval(,)
Jean

Stat Monte Carlo [rlogis] Copy 2.sm (102 KiB) downloaded 36 time(s).



  • New Posts New Posts
  • No New Posts No New Posts