cancel
Showing results for
Did you mean:
cancel
Showing results for
Did you mean:

Community Tip - Your Friends List is a way to easily have access to the community members that you interact with the most! X

6-Contributor

Truncate Array to Count out of Range Results | Monte Carlo

Hello Community,

I have a worksheet running Monte Carlo simulation where I look at the output array and calculate a mean and standard deviation.  I would like to use those results to calculate the number of simulations where the result was out of a range. For example, calculate the number of results than are more than 3 standard deviations from the mean.  I can write "for" loops to do this work, but I feel like there might be a more elegant way to "throw out" out of range elements of an array.

1 ACCEPTED SOLUTION

Accepted Solutions
6-Contributor
(To:LucMeekes)

Luc, your use of the SUM tool got me thinking of combining it with Booleans operators.

Looks like there is a highly compacted way to do this when we combine both.  Thanks for the feedback!

5 REPLIES 5
23-Emerald III
(To:Theo_Gagner)

Yes, there is a smart way, without writing for loops:

Above is the function that counts all values below -0.7.

To count all values above 0.7, change -0.7 to 0.7 and change "lt" to "gt". That results in an error message, because there is no such value. So you have to make sure that there are values in the region you want to count.

Success!
Luc

23-Emerald III
(To:Theo_Gagner)

A small improvement:

Success!
Luc

6-Contributor
(To:LucMeekes)

Luc, your use of the SUM tool got me thinking of combining it with Booleans operators.

Looks like there is a highly compacted way to do this when we combine both.  Thanks for the feedback!

23-Emerald III
(To:Theo_Gagner)

Smart!

24-Ruby V
(To:Theo_Gagner)

For example, calculate the number of results than are more than 3 standard deviations from the mean.  I can write "for" loops to do this work, but I feel like there might be a more elegant way to "throw out" out of range elements of an array.

If your goal is to just count the out of range elements you may use Lucs method.

If your goal is to "throw out" those elements and keeps the rest in a smaller vector you may use a combination of "Match" and "trim".

Announcements
Top Tags