I checked a while back for questions relevant to my own about normalizing numpy arrays but couldn't find any. So I'll pose my question following this line of code:
for i in range(arraytransition.shape[0]):
total = 0.0
for i in range(arraytransition.shape[1]):
total += arraytransition[i, j]
for i in range(arraytransition.shape[1]):
arraytransition[i, j] /= total
'arraytransition' is the array in question. I understand that the code lacks efficiency, but I'm not fluent enough with numpy at the moment to use a more efficient code (I tried but failed). The current problem with this code is that it reproduces each row as totally identical.
What are the potential fixes to this block of code? I would also be happy to know a more efficient way of doing things.
Thanks! This is my first post here and I hope I am
- posting original material
- following all of the appropriate guidelines
If not, please indicate to me what I am doing wrong and I would be happy to correct myself.