RE: combining LOOKUP and IF functions
- From: ntnnj26 <ntnnj26@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Fri, 2 Mar 2007 19:55:03 -0800
Thank you so much for your help, I think I may be approaching the problem
with the wrong tools based on your experience. I am trying to model rolling
a die using serial correlation instead of the natural probability of 1/6. I
will take the info you provided back to the drawing table. Thanks again!
"Joel" wrote:
excel is very nice in entering matrix type data, but has deficienties in.
looking up data with multiple conditions. It may be possible to use Lookup
function for your task but wasn't sure from the description. Lookup has
different mode of operation (see help in excel).
If you had a table with the following numbers
.3
.5
.6
.8
and you look up 4 Lookup will return 3. but the numbers have to be in
increasing order. If the numbers weren't in order like
.6
.5
.8
.3
and you lookup .4. lookup will return .6
If you organize your state machine carefully you may be able to use the
excel spread***. You can always use the VBA Macro to solve your problem.
I used the VBA language in a probabilty course to model shuffling cards. It
worked real well. I was able to output the results of the model into the
excel spread*** and then plot the result of the model.
I also used VBA to produce a seven year model of profits using a Monte Carlo
simulation. In nieither of these cases was I able to use just a spread***.
I had to write VBA code.
"ntnnj26" wrote:
Thank you for your help. I actually have very limited knowledge of state
machines, I am just reading up on the matter now.
I think I may not have phrased my question correctly though. I have 250
randomly generated variables and I need to look them up in the matrix
according to my start state. So I need to involve in the equation the
randomly generated variable, the start state, and the matrix to get the
outcome (which will become the start state for the next step).
"Joel" wrote:
This task is best writen in a custom function. You would pass into the
function the current state and the function would return the next state. It
really requires NO knowledge of excel. It is a simple Basic language program
that anybody who understands state machines as well as you do can write in a
few minutes.
The excel spread*** would simply have the formula =GetState(A5), where
cell A5 contains the current state.
the VBA function would look like this
Function GetState(CurrentState as Integer)
'Your basic code with one of the variables called NextState
GetState = NextState 'The return value of the function gets assigned
'to the function name
End Sub
The code is a random number genator and a two dimensional array.
"ntnnj26" wrote:
I'm trying to use a state transition matrix in Excel. I randomly generate a
percentage and want to lookup the value in a corresponding table where this
value would fall if we sum across the row. For example, the first randomly
generated value is 13.5% and we are starting in state 6. Therefore, I want a
formula that looks in row 6 (starting state) and determines which column
(1-6) has the value 13.5% if you sum the values across (in this case the
answer is 5). Then 5 becomes the new starting state and so on. Is there a
formula or combination of formulas in Excel that can carry out this complex
function?
Thank you.
State transition matrix
1 2 3 4 5 6
1 85.00% 10.50% 3.10% 0.74% 0.66% 0.00%
2 8.90% 79.00% 9.20% 1.70% 1.20% 0.00%
3 1.00% 7.50% 73.00% 15.00% 2.50% 1.00%
4 0.00% 1.00% 13.00% 76.00% 9.00% 1.00%
5 0.00% 2.00% 5.00% 6.00% 71.00% 16.00%
6 0.00% 1.00% 1.00% 6.00% 9.75% 82.00%
- References:
- combining LOOKUP and IF functions
- From: ntnnj26
- RE: combining LOOKUP and IF functions
- From: Joel
- RE: combining LOOKUP and IF functions
- From: ntnnj26
- RE: combining LOOKUP and IF functions
- From: Joel
- combining LOOKUP and IF functions
- Prev by Date: RE: How to write for copying a cell value to another cell
- Next by Date: MAXIF style function
- Previous by thread: RE: combining LOOKUP and IF functions
- Next by thread: RE: combining LOOKUP and IF functions
- Index(es):