Question: using java- simple code 1. In a town, each day is either sunny or rainy. A sunny day is followed by another sunny day with
using java- simple code
1. In a town, each day is either sunny or rainy. A sunny day is followed by another sunny day with probability 0.7, whereas a rainy day is followed by a sunny day with probability 0.4. It rains on Monday. (a) Simulate a Markov chain of 100 days for the weather: First simulate the weather on Tuesday (based on Monday's weather), and then simulate the weather on Wednesday (based on Tuesday's weather), etc. Write down the weather of the 100 days. [Hint: To generate a random number X that takes value 1 with probability 0.7 and 2 otherwise, first generate a uniform random variable U on [0, 1], and then let X if U 0.7 and X2 otherwise.] (b) Repeat (a) but for 10000 days. What proportions of sunny and rainy days do you have? Compare the result to the stationary distribution (which was derived in the lecture)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
