# Probability analysis in Simulink model

1. Jul 10, 2012

### MrsZiggy

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

2. Jul 11, 2012

### Stephen Tashi

You haven't defined what the given information means and you haven't explained what event you want to compute the probability for. For example, suppose the objects begin at distance 10 at time 0. They move toward each other till they are at distance 5 and then move away from each other until they are at distance 10 again. How would the detection process be simulated? If object A detects object B when they are at distance 3 does object B stay detected as the object move together and then away again? Or must A try again to detect B each time the distance changes?

What is the event that the probability function is suppose to compute a probability for?

3. Jul 11, 2012

### MrsZiggy

The initial distance and time will vary based on many other factors. This should be a step that is passively watching the calculated distance with each time-step. At each step, it should sample from a probability curve that is based on distance. As in, at step 1, the distance is 100km and there is a 0% chance of detection, so it passes a 0. At step 100 or so, they might have moved close enough so that the distance is now 50km and the possibility of detection is now 50%. So at this point, it should be a 50/50 chance that it'll be detected (indicated by the block passing out a 1) and a subsequent switch gets flipped that tells everyone a detection has occurred. If that 50/50 chance came up with no detection (indicated by a 0) then it resamples again on the next step based on the newly calculated distance that is passed to it.

I've already got the upstream blocks done (moving the objects, calculating the distance etc) and the downstream (waiting for an indication of 1), its just the probability sampling in the middle where I'm stuck. And this block doesn't have to have any cut offs etc - just as long as the model is running, its constantly sampling for a 1 or 0 based on the probability of detection at the newly computed distance. So other than resampling with every time step, this function is independent of time.

4. Jul 11, 2012

### Stephen Tashi

I don't know whether you are trying to analyze a real world situation or do some sort of class exercise.

From a real world point of view, the model you propose doesn't make sense. If you made an independent random draw to determine detecting at each time step (or each distance step) the probability of drawing the first detection wouldn't be a function of total distance (or time) alone. It would depend on the size of the step. For example if you made one random draw from the distance-vs-probability curve every 0.5 km, you would have a higher probability of detecting the target than if you only make one random draw every 1.0 km, since you get more draws using the 0.5 km interval. You can't make this sort of model "more accurate" by decreasing the size of the interval you use. As the interval size goes toward zero, the probability of immediate detection goes to 1.

5. Jul 12, 2012

### MrsZiggy

This is for a simulink model i am building to do an analysis for a real world problem. For each step the model takes, time is increased by 1 second, and object A will move by about 50m. For probability of detection by distance, I have a lognormal curve leading up to a certain distance means 100% detection rate. How do I set this up in simulink? (Or in matlab code that I will call in the model)? I wanted to use the USS block in simulink as I am under the impression that it is capable of running monte carlo-esq random draws, but I haven't figured that block out at all.

6. Aug 30, 2012

### RG123

This may be a little late but Mathworks has some details on how to perform this type of analysis in Simulink:

http://www.mathworks.com/discovery/monte-carlo-simulation.html

Although there are details on the USS block for it, you don't really want to use it unless you are utilizing robust control methods.