![]() |
|
![]() |
|
|
|
ReliaSoft > Software > RENO > Examples > Example M-1
|
|||||||||||||
Problem Statement:
If it has rained for the past two days, then it will rain tomorrow with probability 0.8. If it rained today but not yesterday, then it will rain tomorrow with probability 0.4. If it rained yesterday but not today, then it will rain tomorrow with probability 0.3. If it has not rained in the past two days, then it will rain tomorrow with probability 0.2. We can transform the above model into a Markov chain by saying that the state at any time is determined by the weather conditions during both that day and the previous day. In other words, we can say that the process is in: State 0 if it rained both today and yesterday. State 1 if it rained today and but not yesterday. State 2 if it rained yesterday but not today. State 3 if it did not rain either yesterday or today. The preceding would then represent a four-state Markov chain having the following transition probability matrix:
The limiting probabilities for these states are found respectively to be 8/30, 4/30, 4/30 and 14/30. Therefore, we have: Proportion of Rain = 0.8 * 8 / 30 + 0.4 * 4/30 + 0.3 * 4/30 + 0.2 * 14/30 = 0.4 RENO Solution: Define three Storage Variables to keep track of the weather conditions for Yesterday, Today and Tomorrow, as shown next for Today. At each iteration, Yesterday and Today are reset to reflect the new scenario, i.e. Today becomes Yesterday and Tomorrow becomes Today.
Define four Constants to represent the probability of rain tomorrow: if it rained for the last two days (R_R = .8); if it rained today but not yesterday (NR_R = .4); if it rained yesterday but not today (R_NR = .3); and if it has not rained today or yesterday (NR_NR = .2). The "R_R" Constant is shown next as an example.
Define a uniform Probability to determine the probability that it will rain on a given day.
Define a Constant called "Loop" to specify the number of loops that will be performed during a single simulation run.
In addition, define two Storage Variables called "Probability" and "Rain Counter" to hold the values that are passed during the simulation for the probability of rain tomorrow and the number of days that it rains, respectively. These should also be reset after each simulation.
Construct the flowchart as follows:
The "Start" Flag that begins each loop of the simulation has ordered relations (identified with numbers over the lines) leading first to the Standard Block that indicates whether it rained Yesterday and then to the Standard Block that indicates whether it rained Today (based on the previous loop of the simulation). If the execution were to happen in the opposite order, the information on whether or not it rained today would be overwritten for the next loop. You can set the ordered relations by selecting the source block (i.e. the Flag Marker), choosing Ordered Relations, then drawing the relationship lines. The Standard Blocks are shown next.
A Logic Gate construct checks to see whether it has rained for the last two days. If true, then the R_R probability (.8) is passed to the Result Storage Block called "Probabilities," which holds the last value passed to it and updates the Storage Variable called "Probability." If false, then the simulation moves to a Conditional Block that checks to see whether it rained yesterday. If true, then the R_NR probability (.3) is passed. If false, then the simulation moves to another Conditional Block that checks to see whether it rained today. If true, then the NR_R probability (.4) is passed and if false, then the NR_NR probability (.2) is passed. (The extra Standard Block, "Didn’t Rain For Two Days," in the FALSE path is just used to pass the NR_NR probability to the Result Storage Block, and evaluates to IN.)
Another Conditional Block uses the probability that is passed from the Result Storage Block (.8, .4, .3 or .2) and the uniform probability of rain, "ProbabilityRain," to determine whether it will rain tomorrow.
Two Standard Blocks, "Rain" and "No Rain," evaluate to IN and update the Storage Variable "Tomorrow." A Counter Block called "Rain Counter" keeps track of how many days it rains.
The loop that is required to solve this example is constructed by using a Counter Block called "Day Counter" that is reset after each simulation to keep track of how many days have been simulated. This value is passed to a Conditional Block called "Done?" that checks the "Loop" Constant to determine whether the specified number of days, 5000, have been simulated.
If the specified number of days have not yet been simulated, then the FALSE path leads to a Reset Block that points to a Go To Flag that points to the "Start" Flag, so that the simulation can move through the flowchart again. Once the specified number of days have been simulated, the Standard Block "Done" calculates the number of days that it rained divided by the number of days simulated.
The Result Storage "Rain Portion" stores the last value passed to it. After performing 1 simulation (since the loop is included in the flowchart), the results are displayed in the Simulation Results Explorer and in the flowchart. The proportion of rainy days is found to be 40.34%, which is similar to the result from the Markov chain analysis. A RENO project with the solution for this example (called "Rain Prediction.rnp") is shipped with the software and stored in the Examples\Misc Fun folder in the application directory (e.g. C:\Program Files\ReliaSoft\RENO\Examples\Misc Fun\Rain Prediction.rnp).
|
|
||||||||||||
|
[Home] [Software] [Training] [Consulting] [Resources] [Corporate] [Search] [Site Map] [weibull.com] |
|
|
ReliaSoft is a registered trademark of ReliaSoft Corporation in the United States and other countries. |
LEGAL [Terms of Use] [Linking Guidelines] |
| Copyright ©1992-2008 ReliaSoft Corporation, All Rights Reserved |
Contact Webmaster |