cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead 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

Truncate Array to Count out of Range Results | Monte Carlo

Theo_Gagner
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
Theo_Gagner
6-Contributor
(To:LucMeekes)

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

Sum of Boolean.PNG

 

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

View solution in original post

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

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

LM_20181105_Count.png

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

LucMeekes
23-Emerald III
(To:Theo_Gagner)

A small improvement:

LM_20181105_Count.png

Success!
Luc

Theo_Gagner
6-Contributor
(To:LucMeekes)

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

Sum of Boolean.PNG

 

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

LucMeekes
23-Emerald III
(To:Theo_Gagner)

Smart!


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".

 

Top Tags