Matrix multiplication - speed

Discussion in 'CT4' started by Ex-muso, Feb 18, 2012.

  1. Ex-muso

    Ex-muso Member

    Q3.5
    By working out all possible paths, calculating probabilities and summing I can get the required answer quickly.

    However, using the recommended method of post-multiplying the vector by the transition matrix until reaching n+5, I find it takes way longer and I feel far more likely to make a mistake too. I feel like i must be missing something on multiplying matrices at speed. Could someone enlighten me?
     
  2. Viki2010

    Viki2010 Member

    But how are you calculating P^5?

    I think the fastest way is to calculate P^2 and P^3 and then only calculate the required value in P^5.
     
  3. Ex-muso

    Ex-muso Member

    Thanks for the reply.

    Your suggested approach looks like the second approach in the course notes solutions. This, for me, is still much slower than the other method I described. As I said, I must be missing something in the speed at which matrices can be multiplied.
     
  4. Calum

    Calum Member

    If there are a small number of states and the transitions are straightforward, yes, it *can* be faster to calculate them directly, especially if the matrix is sparse.

    The danger is that you have to make sure you've included every possible path; multiplying the matrices out in full is a more mechanical process which avoids this source of error.
     
  5. Viki2010

    Viki2010 Member

    q&a part5-revision-q5.5 ii

    how can we get (P^6)1,5 without calculating P^3 *P^3?

    the solution is just 1 line of calculations but I would have a hard time on the exam to follow this way...
     
  6. Viki2010

    Viki2010 Member

    anybody? :eek:
     
  7. Ex-muso

    Ex-muso Member

    Right.

    Am understanding this much better now. I think the answer to the original question, for anyone interested, was:

    1) practice
    2) the M+ function on the calculator seems to me to make summing the various multiplications a smoother process in general

    Sorry if that's stating the obvious for some - matrices all new here!

    (btw, on the subject of useful calculator techniques, I assume everyone has checked out the stats functions for use for CT3 and CT4? Again, I might easily have missed this, but I'm glad I found it - speeds up variances etc)

    Viki - having got a bit more comfortable with the basic process now, I can't quite see why getting (P^6)1,5 by using P^3 * P^3 is any more onerous than what went before. Are you wondering if there's a shortcut?
     
  8. Viki2010

    Viki2010 Member

    yes, becasue the solution just shows one line and I was computing full matrix P^3 in order to get P^6 (1,5).



     
  9. John Potter

    John Potter ActEd Tutor Staff Member

    1) You can calculate P^6 and read out the relevant entry. Try to be clever how you do this, eg if you only need the top right of P^6 then only calculate the top row and last column of P^3.
    2) You could apply P six times to the row vector (1,0,0) or you could apply P^2 three times to the row vector
    3) You could co it from scratch thinking about all the possible paths. This is really all the above methods are doing anyway. I totally agree with Calum above that this is dangerous because you might miss one of the possible paths

    John
     

Share This Page