loop? maybe?

H

heidi taynton

Hey guys,

Sorry for being such a noob with this stuff and the language is hard for me to read through with the online manuals... i can do math speak, and science speak... not so much programming/code speak... so when you say pickle... i think food....


Anyways,

I have an array and I want to turn it into a new array. where


nlines = 188
new_array=n.array(nlines)

for i in arange(nlines):

##### and here i want to tell it to read old_array and take n data points where new_n=1.1**old_n ... take the mean of those data points and put them in the first spot in the array.... then loop through with until the array is full? If it doesn't make sense, i can try to clarify some more...


Thanks, you guys are life savers,
hi
 
M

Mike Driscoll

Hey guys,

Sorry for being such a noob with this stuff and the language is hard for me to read through with the online manuals...  i can do math speak, and science speak... not so much programming/code speak... so when you say pickle... i think food....

Anyways,

I have an array and I want to turn it into a new array.   where

nlines = 188
new_array=n.array(nlines)

for i in arange(nlines):

#####   and here i want to tell it to read old_array and take  n  data points  where new_n=1.1**old_n ... take the mean of those data points and put them in the first spot in the array....    then loop through with until the array is full?      If it doesn't make sense, i can try to clarify some more...

Thanks, you guys are life savers,
hi

I'm probably missing something, but is this sort of what you are
looking for?

<code>

nlines = 188
new_array = [] # this creates a list
for i in range(nlines):
new_n = 1.1 ** i
mean = (new_n + i) / 2
new_array.append(mean)

</code>

If you wanted a cumulative mean of the values, then you'll have to
change it slightly of course, probably by using a nested loop.

Hopefully this isn't a homework question, but even if it is, it's an
interesting exercise.

Mike
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,175
Messages
2,570,942
Members
47,489
Latest member
BrigidaD91

Latest Threads

Top