Movatterモバイル変換


[0]ホーム

URL:


How to create 3 dimension array from 1 & 2 dimension array

Steve Holdensholden at holdenweb.com
Sat Apr 28 11:29:55 EDT 2001


"Tawee Laoitichote" <astpspd at pea.or.th> wrote in messagenews: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 problemyou were trying to solve. I suspect you don't want to make your postings toolong, but maybe some more information would help.I did some work on finite-state automata a long time ago, and presume youare looking at similar areas of application.However, remember that adding a vector (1-D array) to a 2-D array doesn'tgive you a 3-D array! A 3-D array is actually some number of 2-D arrays, somaybe the data structure you are looking for isn't a 3-D array at all? Maybewhat you need is a vector of tuples whose first elements are the items ofthe 1-D array and whose second elements are the rows or columns ofthe 2-Darray? Or possibly even a class, which might be more flexible.regards Steve


More information about the Python-listmailing list

[8]ページ先頭

©2009-2025 Movatter.jp