*Problem*: Analyze a chaotic one-dimensional map: Write a program OneDMapAnalyze.py that reads the data in OneDMap.txt. Calculate the mean value of the iterates, printing the result to the terminal; again annotate the output so that it is understandable. Determine the fraction of iterates that have x > 0.5. Also, print out that result.
*The previous problem that I have already done:* Iterate a chaotic one-dimensional map: Write a program OneDMapIterate.py that iterates the function f(x) = 4.0 x ( 1 - x ). First, set the initial condition x = 0.3. Then apply f(x) repeatedly to each new x. Iterate for 100 steps, printing on each line the iteration number and the successive x values to file OneDMap.txt. My program: #Imports math functions from math import * #Initial condition for x x = 0.3 #Opens onedmap.txt file and writes to it file = open('onedmap.txt','w') #Loop, replaces old x with new x i amount of times for i in range(1,101): x = 4.0*x*(1.0-x) #Writes contents of loop to file print >> file, 'Iterate number ', i, ': ', x #Closes file file.close() My problem is, I don't know how to get ONLY the numbers from the OneDMap.txt file. Also, assuming that I am able to do just that, how would I get them into an array? -- tell me i can't do it, then i'll prove you wrong! facebook me
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor