How to create 3 dimension array from 1 & 2 dimension array
Steve Holden
sholden at holdenweb.com
Sat Apr 28 11:29:55 EDT 2001
"Tawee Laoitichote" <astpspd at pea.or.th> wrote in message
news:mailman.988352080.15579.python-list at python.org...
> Dear John,
>
> The 2-d array is to keep the state transition probabilities table whilst
> the 1-d array is to keep each transition step. Each step is calculated
> then keep in the state transition table then I get the 3 dimension
> array. In my case, the 2-d array has a shape of 4 by 4 with 3-step
> transition.
>
> Say :
>
> py> print P1
> [[ 0.0803014 0.18393972 0.36787944 0.36787944]
> [ 0.63212056 0.36787944 0. 0. ]
> [ 0.26424112 0.36787944 0.36787944 0. ]
> [ 0.0803014 0.18393972 0.36787944 0.36787944]]
>
> py> print P1.shape
> (4, 4)
>
> py> print P2
> [[ 0.2494705 0.28544118 0.3002118 0.16487652]
> [ 0.28330432 0.25160736 0.23254416 0.23254416]
> [ 0.35097196 0.319275 0.23254416 0.09720887]
> [ 0.2494705 0.28544118 0.3002118 0.16487652]]
>
> py> print P3
> [[ 0.29303419 0.29166457 0.2628715 0.15242975]
> [ 0.26191727 0.27299442 0.27531827 0.18977005]
> [ 0.29925757 0.28544118 0.25042473 0.16487652]
> [ 0.29303419 0.29166457 0.2628715 0.15242975]]
>
Tawee:
I think it might help if you were a little more verbose about the problem
you were trying to solve. I suspect you don't want to make your postings too
long, but maybe some more information would help.
I did some work on finite-state automata a long time ago, and presume you
are looking at similar areas of application.
However, remember that adding a vector (1-D array) to a 2-D array doesn't
give you a 3-D array! A 3-D array is actually some number of 2-D arrays, so
maybe the data structure you are looking for isn't a 3-D array at all? Maybe
what you need is a vector of tuples whose first elements are the items of
the 1-D array and whose second elements are the rows or columns ofthe 2-D
array? Or possibly even a class, which might be more flexible.
regards
Steve
More information about the Python-list
mailing list