Monte Carlo type of simulation in Simulink using USS block?

Asked by Michelle on 10 Jul 2012
Latest activity Commented on by Ryan G on 13 Jul 2012

Here are the basics - I've got a model with a computed distance between 2 objects. The likelihood that object A will detect object B is a probability dependent on distance (and its a cumulative lognormal curve).

I want to include a probability function based on that computed distance. So that at X meters, the probability of detection is 20%. At Y distance its 50% etc. At each step of the model, the distance will be different, so it needs to redo its random draw from the probability function and output whether or not object B was detected.

I was under the impression that the uncertain state block within the robust control toolbox was the direction to go, but so far I haven't been able to decipher the "help" information to learn how to use and apply it. (And as far as I can understand, it would be ideal b/c I can also run the model varying all the uncertain variables a certain number of times from the command line).

HELP PLEASE!!!

4 Comments

Michelle on 12 Jul 2012

It is not at the moment. If it needs to be, I'm ok with figuring out how to do that (I think).

I would be THRILLED to learn of a good way to do a monte carlo type of random draw based on an inputted distance!! I am very flexible as to the manner in which this is accomplished. I was under the impression that the USS block would be my best option.

Ryan G on 12 Jul 2012

If your model is not state space already I would recommend not going that route. There is a demo showing how to do monte carlo with USS but there are many ways to do it without a state space.

If you can post a screenshot of roughly what you're modeling I can make some recommendations. You can use a service like imgur.com or whatever works for you.

Michelle on 13 Jul 2012

At the moment, this section is a blank slate (well, blank subsystem actually). I've got computed distance (recalculated at each step) incoming, and outgoing I'd like to have a 1 (detection) or 0 (no detection) to trip a switch for an indicator. The middle part is blank b/c i had wrongly assumed that the USS block would be a simple way to do a probability draw!

Michelle

1 Answer

Answer by Ryan G on 13 Jul 2012
Edited by Ryan G on 13 Aug 2012

There are Uniform and Normal Random Number blocks in Simulink you can use to create a random draw (assuming you want this to change with each step). You can setup a comparison for random detection (1's and 0's) like this in simulink:

Unfiform Random Number block with minimum set to 0 -> Quantizer with interval set to one

This will output 1's and 0's with 50% chance of either.

To achieve a 20% detection rate you could do copy what's above, set the max of uniform random number to 4 and after the quantizer use a compare to zero block setup as ==0

Since the odds of a zero out of the quantizer should be 1/5 the output of the compare to zero should be true 20% of the time. You can repeat a similar process for any % you want.

See this page for more info: Monte Carlo Simulation with MATLAB and Simulink

2 Comments

Michelle on 13 Jul 2012

But how do I make the 50% vs 20% etc based on the input distance?

Ryan G on 13 Jul 2012

In the library under Signal Library there is a multiport switch, which is essentially a selector. The first input to the switch would be the distance selection, ie if distance == 1 choose 1 if distance == 2 choose to, the rest of the inputs would correspond to the random values as described above.

Ryan G

Contact us