Community Tip - Want the oppurtunity to discuss enhancements to PTC products? Join a working group! X
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.
Solved! Go to Solution.
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!
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
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!
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".