1

Transition Probability is given as

enter image description here

e.g., for one product, when the current price is High, the probability of next period being High Price is 0.3, and being Low price is 0.7.

My question is that for two independent products, what is the transition probability?

I'm looking for some results like the following table:

enter image description here

e.g., given the current price level is H for product 1 and H for product 2, the probability of being L for 1 and H for 2 is 0.7*0.3 = 0.21.

The current code that I am using is the following:

from sklearn.utils.extmath import cartesian
pr = np.array([[0.3,0.7],[0.6,0.4]])
P = np.zeros((4,4))
count = 0
for i in range(2):
    for j in range(2):
        P[count] = cartesian((pr[i],pr[j])).prod(1)
        count += 1
P

It works well for two products, but for more products it would be very confusing. e.g. For four independent products, the transition matrix is 16*16: for each current state (e.g. HHHH), there are 16 possible future states, e.g. (HHHH, HHHL, HHLH, HHLL, HLHH, .... etc)

Is there an easy and clear way to do this?

Titanic
  • 557
  • 1
  • 8
  • 21
  • It's true that the transition table increases rapidly (exponentially), but do you really need to have the complete table in memory? why not managing only the basic table, and then computing the specific transition from vector a to vector b only when required? – Eyal Schneider Mar 20 '14 at 16:11
  • I'm solving a dynamic programming question, and the complete table is required. – Titanic Mar 20 '14 at 17:45
  • I guess a real improvement is impossible given your constraints. Perhaps if you reveal the complete problem you are trying to solve, new approaches will be suggested. – Eyal Schneider Mar 20 '14 at 20:10

1 Answers1

0

You are generating a simple markov TM if I am correct.

Now you want to look at what the transition probability is for 1 product, given two others? Am I correct? Well, then you are just going to learn again from the data, but this time, look at each occurance of pairs of data and treat them as an n-gram.

Your matrix is indeed going to get really big, but that shouldn't pose a problem right away.

If you want to look back a big amount of periods, then you might want to consider another technique that can handle timeseries better.

dorien
  • 5,265
  • 10
  • 57
  • 116
  • There are only two price levels for each product: H and L, e.g. the price of a hotdog from two hotdog stands A and B can either be $1 or $2. So there are always four states in any periods: 11, 12, 21, 22. So the matrix is not going to get very big. – Titanic Mar 20 '14 at 17:50
  • Ok, you are not looking back any further. To calculate the transition matrix for more products, just set a for look over your current code. It will require some paying attention, but it will totally work. – dorien Mar 21 '14 at 15:58