1. Limited time only! Sign up for a free 30min personal tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Homework Help: Noisy weather sensor

  1. Feb 24, 2014 #1
    1. The problem statement, all variables and given/known data

    An imperfect sensor measures the weather (which can only be either sunny, cloudy or rainy) in a fixed place. Suppose we know the weather on the first day was sunny. In the following days we obtain the measurements cloudy, cloudy, rainy, sunny.

    What is the probability that the weather at day 5 is indeed sunny as our sensor says?

    2. Relevant equations

    The noise of the sensor is given by a known stochastic matrix:

    S_{ij} = p(z_n = j | x_n = i)

    where [itex]z_n[/itex] refers to a measurement and [itex]x_n[/itex] to the real state at day n, and [itex]i[/itex] and [itex]j[/itex] refer to the possible weathers (sunny, cloudy, rainy).

    3. The attempt at a solution

    I just tried to find a general formulation, as I saw that I would probably need it later.

    By straightforward application of Bayes Rule I've found the expression:

    p(x_n = i | z_n = j) = \frac{p(z_n = j | x_n = i)p(x_n = i)}{p(z_n = j)}

    Now, here is where I have trouble. How can I find out the real probability that one day had a certain weather?

    In a previous exercise I was presented with a similar situation and was given a stochastic matrix that described the probability of weather on a certain day based on the weather of the previous day. I am not sure that it applies also to this exercise. Is there any way to solve it with the given data?
    Last edited: Feb 24, 2014
  2. jcsd
  3. Feb 24, 2014 #2
    I had misread the statement of the problem. I have update the info now. Can someone help me?
  4. Feb 24, 2014 #3
    I've worked out this code for the Bayes Filter, would you mind telling me if I've done it right?
    Code (Text):

    function newx = posterior(z, x0, transmat, sensmat)
      if size(z)(2) = 0
        newx = x0
      prior = posterior(z(1:end-1), x0, transmat, sensmat)*transmat(:,x)   
      norm = sensmat*prior  
      newx = sensmat(x)(z)* prior / norm
    Last edited: Feb 24, 2014
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook

Have something to add?
Draft saved Draft deleted