Last login: Mon Jan 23 10:28:06 on ttys000 odd-2% ls 1f88.ent dynamics.ppt 2008_02_19_irina_collab.pdf eclipse Applications error.txt CV_NIH_2008_02_19.pdf groel-c7.mrc DVDTemp groel.12A.mrc Desktop groel.12A.pub.mrc Documents groel.published.12.mrc Downloads groel.xray.12A.mrc Dropbox installed DumpLog 11-06-12 17:56 lib DumpLog 11-06-19 22:42 mail DumpLog 11-06-19 22:46 me.jpg DumpLog 11-06-19 22:54 me.psd DumpLog 11-06-19 22:59 mmcpn.py DumpLog 11-06-19 23:01 mmcpn.side.gif DumpLog 11-06-19 23:07 mmcpn.top.gif EMAN p1.txt EMAN2 p2.txt EMAN2.odp pro EMAN2.old proc3d.filt EMAN2.ppt proc3d.raddist EMAN2DB r_07_04.hdf Image Data Converter SR r_09_04.hdf ImageMagick-6.4.0 r_16_02.hdf Library r_16_02.jpg Movies r_16_02f.hdf Music r_35_02.hdf Pictures refine Public refine.log QtSDK result.txt Reference2.pdf s2 Sites scripps.pdf StrucFact.sm session9.txt UCLA.pdf share VirtualBox VMs snapshot1.png aacmsched.pdf speed.hed aacmsched2.pdf speed.img abstract.doc std.ics bin test.html burn test.mov cam.html test.py cd test1.mp4 chimera_movie.mov test2.py chimera_movie.mp4 test2.pyc chimera_movie2.mp4 tmp classes.png tomotrackbox.py ctf.fg1d.ps tst.hdf ctfparm.txt tst.txt d video.mpg dot.hdf wp dot2.hdf x.py odd-2% cd odd-2% ls 1f88.ent dynamics.ppt 2008_02_19_irina_collab.pdf eclipse Applications error.txt CV_NIH_2008_02_19.pdf groel-c7.mrc DVDTemp groel.12A.mrc Desktop groel.12A.pub.mrc Documents groel.published.12.mrc Downloads groel.xray.12A.mrc Dropbox installed DumpLog 11-06-12 17:56 lib DumpLog 11-06-19 22:42 mail DumpLog 11-06-19 22:46 me.jpg DumpLog 11-06-19 22:54 me.psd DumpLog 11-06-19 22:59 mmcpn.py DumpLog 11-06-19 23:01 mmcpn.side.gif DumpLog 11-06-19 23:07 mmcpn.top.gif EMAN p1.txt EMAN2 p2.txt EMAN2.odp pro EMAN2.old proc3d.filt EMAN2.ppt proc3d.raddist EMAN2DB r_07_04.hdf Image Data Converter SR r_09_04.hdf ImageMagick-6.4.0 r_16_02.hdf Library r_16_02.jpg Movies r_16_02f.hdf Music r_35_02.hdf Pictures refine Public refine.log QtSDK result.txt Reference2.pdf s2 Sites scripps.pdf StrucFact.sm session9.txt UCLA.pdf share VirtualBox VMs snapshot1.png aacmsched.pdf speed.hed aacmsched2.pdf speed.img abstract.doc std.ics bin test.html burn test.mov cam.html test.py cd test1.mp4 chimera_movie.mov test2.py chimera_movie.mp4 test2.pyc chimera_movie2.mp4 tmp classes.png tomotrackbox.py ctf.fg1d.ps tst.hdf ctfparm.txt tst.txt d video.mpg dot.hdf wp dot2.hdf x.py odd-2% cd wp/lecture/2012_01_Intro_Programming odd-2% ls Extra_5.pdf Lecture2.key Lecture5.key lec4 Homework2.pdf Lecture2.pdf Lecture5.pdf lec5 Homework3.pdf Lecture3.key Lecture6.key lec6 Homework4.pdf Lecture3.pdf day1handout.pages terminal_5.txt Homework_5.pdf Lecture4.key grades.numbers Lecture1.key Lecture4.pdf lec3 odd-2% cd lec6 odd-2% ls hw1.py hw5_1.txt hw5_2.txt odd-2% odd-2% more hw1.py from sys import argv,exit data=[float(i) for i in open(argv[1],"r").read().split()] print "{} values go from {:.2f} to {:.2f}".format(len(data),min(data),max(data)) minbin=float(raw_input("Minimum: ")) maxbin=float(raw_input("Maximum: ")) nbins=int(raw_input("# bins: ")) binstep=(maxbin-minbin)/float(nbins) binmins=[i*binstep+minbin for i in xrange(nbins)] binmaxs=[(i+1)*binstep+minbin for i in xrange(nbins)] bins=[0]*nbins for d in data: for b in xrange(nbins): if d>binmins[b] and d<=binmaxs[b] : bins[b]+=1 for b in xrange(nbins): print "{0:.2f} - {1:.2f} : {2}".format(binmins[b],binmaxs[b],bins[b]) odd-2% cls odd-2% vi x.py odd-2% ipython Python 2.7.1 (r271:86832, Jun 16 2011, 16:59:05) Type "copyright", "credits" or "license" for more information. IPython 0.10.2 -- An enhanced Interactive Python. ? -> Introduction and overview of IPython's features. %quickref -> Quick reference. help -> Python's own help system. object? -> Details about 'object'. ?object also works, ?? prints more. In [1]: a=[1,2] In [2]: b=a*5 In [3]: b Out[3]: [1, 2, 1, 2, 1, 2, 1, 2, 1, 2] In [4]: Do you really want to exit ([y]/n)? odd-2% vi x.py odd-2% ls hw1.py hw5_1.txt hw5_2.txt x.py odd-2% python x.py hw5_1.txt Enter the minimum (0.28):0 Enter the maximum (6.7):10 Enter the number of bins (1000 values):20 Traceback (most recent call last): File "x.py", line 14, in minval=[minv+i*step for i in range(nbins)] TypeError: range() integer end argument expected, got float. odd-2% !vi vi x.py odd-2% python x.py hw5_1.txt Enter the minimum (0.28):0 Enter the maximum (6.7):10 Enter the number of bins (1000 values):20 0 - 0.5: 6 0.5 - 1: 14 1 - 1.5: 48 1.5 - 2: 84 2 - 2.5: 162 2.5 - 3: 208 3 - 3.5: 174 3.5 - 4: 149 4 - 4.5: 80 4.5 - 5: 42 5 - 5.5: 22 5.5 - 6: 10 6 - 6.5: 0 6.5 - 7: 1 7 - 7.5: 0 7.5 - 8: 0 8 - 8.5: 0 8.5 - 9: 0 9 - 9.5: 0 9.5 - 10: 0 odd-2% !vi vi x.py odd-2% python Python 2.7.1 (r271:86832, Jun 16 2011, 16:59:05) [GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> 110.1/6 18.349999999999998 >>> 110.1//6 18.0 >>> odd-2% vi x.py odd-2% python x.py hw5_1.txt Enter the minimum (0.28):0 Enter the maximum (6.7):10 Enter the number of bins (1000 values):20 Traceback (most recent call last): File "x.py", line 24, in print "%1.2g - %1.2g: %d"%(minval[b],maxval[b],bins[b]) NameError: name 'minval' is not defined odd-2% !vi vi x.py odd-2% python x.py hw5_1.txt Enter the minimum (0.28):0 Enter the maximum (6.7):10 Enter the number of bins (1000 values):20 0 - 0.5: 6 0.5 - 1: 14 1 - 1.5: 48 1.5 - 2: 84 2 - 2.5: 162 2.5 - 3: 208 3 - 3.5: 174 3.5 - 4: 149 4 - 4.5: 80 4.5 - 5: 42 5 - 5.5: 22 5.5 - 6: 10 6 - 6.5: 0 6.5 - 7: 1 7 - 7.5: 0 7.5 - 8: 0 8 - 8.5: 0 8.5 - 9: 0 9 - 9.5: 0 9.5 - 10: 0 odd-2% !vi vi x.py odd-2% python x.py hw5_1.txt Enter the minimum (0.28):0 Enter the maximum (6.7):10 Enter the number of bins (1000 values):20 0 - 0.5: 6 # 0.5 - 1: 14 #### 1 - 1.5: 48 ############# 1.5 - 2: 84 ######################## 2 - 2.5: 162 ############################################## 2.5 - 3: 208 ############################################################ 3 - 3.5: 174 ################################################## 3.5 - 4: 149 ########################################## 4 - 4.5: 80 ####################### 4.5 - 5: 42 ############ 5 - 5.5: 22 ###### 5.5 - 6: 10 ## 6 - 6.5: 0 6.5 - 7: 1 7 - 7.5: 0 7.5 - 8: 0 8 - 8.5: 0 8.5 - 9: 0 9 - 9.5: 0 9.5 - 10: 0 odd-2% python x.py hw5_2.txt Enter the minimum (7.3):0 Enter the maximum (33):50 Enter the number of bins (200 values):22 0 - 2.3: 0 2.3 - 4.5: 0 4.5 - 6.8: 0 6.8 - 9.1: 21 ################## 9.1 - 11: 68 ############################################################ 11 - 14: 11 ######### 14 - 16: 0 16 - 18: 0 18 - 20: 0 20 - 23: 0 23 - 25: 0 25 - 27: 0 27 - 30: 29 ######################### 30 - 32: 67 ########################################################### 32 - 34: 4 ### 34 - 36: 0 36 - 39: 0 39 - 41: 0 41 - 43: 0 43 - 45: 0 45 - 48: 0 48 - 50: 0 odd-2% sudo easy_install neurolab odd-2% ls hw1.py hw5_1.txt hw5_2.txt x.py odd-2% ipython --pylab Python 2.7.1 (r271:86832, Jun 16 2011, 16:59:05) Type "copyright", "credits" or "license" for more information. IPython 0.10.2 -- An enhanced Interactive Python. ? -> Introduction and overview of IPython's features. %quickref -> Quick reference. help -> Python's own help system. object? -> Details about 'object'. ?object also works, ?? prints more. Welcome to pylab, a matplotlib-based Python environment. For more information, type 'help(pylab)'. In [1]: arange(0,1,.05) Out[1]: array([ 0. , 0.05, 0.1 , 0.15, 0.2 , 0.25, 0.3 , 0.35, 0.4 , 0.45, 0.5 , 0.55, 0.6 , 0.65, 0.7 , 0.75, 0.8 , 0.85, 0.9 , 0.95]) In [2]: In [3]: x=arange(0,2*pi,.05) In [4]: x Out[4]: array([ 0. , 0.05, 0.1 , 0.15, 0.2 , 0.25, 0.3 , 0.35, 0.4 , 0.45, 0.5 , 0.55, 0.6 , 0.65, 0.7 , 0.75, 0.8 , 0.85, 0.9 , 0.95, 1. , 1.05, 1.1 , 1.15, 1.2 , 1.25, 1.3 , 1.35, 1.4 , 1.45, 1.5 , 1.55, 1.6 , 1.65, 1.7 , 1.75, 1.8 , 1.85, 1.9 , 1.95, 2. , 2.05, 2.1 , 2.15, 2.2 , 2.25, 2.3 , 2.35, 2.4 , 2.45, 2.5 , 2.55, 2.6 , 2.65, 2.7 , 2.75, 2.8 , 2.85, 2.9 , 2.95, 3. , 3.05, 3.1 , 3.15, 3.2 , 3.25, 3.3 , 3.35, 3.4 , 3.45, 3.5 , 3.55, 3.6 , 3.65, 3.7 , 3.75, 3.8 , 3.85, 3.9 , 3.95, 4. , 4.05, 4.1 , 4.15, 4.2 , 4.25, 4.3 , 4.35, 4.4 , 4.45, 4.5 , 4.55, 4.6 , 4.65, 4.7 , 4.75, 4.8 , 4.85, 4.9 , 4.95, 5. , 5.05, 5.1 , 5.15, 5.2 , 5.25, 5.3 , 5.35, 5.4 , 5.45, 5.5 , 5.55, 5.6 , 5.65, 5.7 , 5.75, 5.8 , 5.85, 5.9 , 5.95, 6. , 6.05, 6.1 , 6.15, 6.2 , 6.25]) In [5]: x[5:10] Out[5]: array([ 0.25, 0.3 , 0.35, 0.4 , 0.45]) In [6]: x[3] Out[6]: 0.15000000000000002 In [7]: x.typy --------------------------------------------------------------------------- AttributeError Traceback (most recent call last) /Users/stevel/wp/lecture/2012_01_Intro_Programming/lec6/ in () AttributeError: 'numpy.ndarray' object has no attribute 'typy' In [8]: x.type --------------------------------------------------------------------------- AttributeError Traceback (most recent call last) /Users/stevel/wp/lecture/2012_01_Intro_Programming/lec6/ in () AttributeError: 'numpy.ndarray' object has no attribute 'type' In [9]: x.dtype Out[9]: dtype('float64') In [10]: x Out[10]: array([ 0. , 0.05, 0.1 , 0.15, 0.2 , 0.25, 0.3 , 0.35, 0.4 , 0.45, 0.5 , 0.55, 0.6 , 0.65, 0.7 , 0.75, 0.8 , 0.85, 0.9 , 0.95, 1. , 1.05, 1.1 , 1.15, 1.2 , 1.25, 1.3 , 1.35, 1.4 , 1.45, 1.5 , 1.55, 1.6 , 1.65, 1.7 , 1.75, 1.8 , 1.85, 1.9 , 1.95, 2. , 2.05, 2.1 , 2.15, 2.2 , 2.25, 2.3 , 2.35, 2.4 , 2.45, 2.5 , 2.55, 2.6 , 2.65, 2.7 , 2.75, 2.8 , 2.85, 2.9 , 2.95, 3. , 3.05, 3.1 , 3.15, 3.2 , 3.25, 3.3 , 3.35, 3.4 , 3.45, 3.5 , 3.55, 3.6 , 3.65, 3.7 , 3.75, 3.8 , 3.85, 3.9 , 3.95, 4. , 4.05, 4.1 , 4.15, 4.2 , 4.25, 4.3 , 4.35, 4.4 , 4.45, 4.5 , 4.55, 4.6 , 4.65, 4.7 , 4.75, 4.8 , 4.85, 4.9 , 4.95, 5. , 5.05, 5.1 , 5.15, 5.2 , 5.25, 5.3 , 5.35, 5.4 , 5.45, 5.5 , 5.55, 5.6 , 5.65, 5.7 , 5.75, 5.8 , 5.85, 5.9 , 5.95, 6. , 6.05, 6.1 , 6.15, 6.2 , 6.25]) In [11]: x[0]=1 In [12]: x Out[12]: array([ 1. , 0.05, 0.1 , 0.15, 0.2 , 0.25, 0.3 , 0.35, 0.4 , 0.45, 0.5 , 0.55, 0.6 , 0.65, 0.7 , 0.75, 0.8 , 0.85, 0.9 , 0.95, 1. , 1.05, 1.1 , 1.15, 1.2 , 1.25, 1.3 , 1.35, 1.4 , 1.45, 1.5 , 1.55, 1.6 , 1.65, 1.7 , 1.75, 1.8 , 1.85, 1.9 , 1.95, 2. , 2.05, 2.1 , 2.15, 2.2 , 2.25, 2.3 , 2.35, 2.4 , 2.45, 2.5 , 2.55, 2.6 , 2.65, 2.7 , 2.75, 2.8 , 2.85, 2.9 , 2.95, 3. , 3.05, 3.1 , 3.15, 3.2 , 3.25, 3.3 , 3.35, 3.4 , 3.45, 3.5 , 3.55, 3.6 , 3.65, 3.7 , 3.75, 3.8 , 3.85, 3.9 , 3.95, 4. , 4.05, 4.1 , 4.15, 4.2 , 4.25, 4.3 , 4.35, 4.4 , 4.45, 4.5 , 4.55, 4.6 , 4.65, 4.7 , 4.75, 4.8 , 4.85, 4.9 , 4.95, 5. , 5.05, 5.1 , 5.15, 5.2 , 5.25, 5.3 , 5.35, 5.4 , 5.45, 5.5 , 5.55, 5.6 , 5.65, 5.7 , 5.75, 5.8 , 5.85, 5.9 , 5.95, 6. , 6.05, 6.1 , 6.15, 6.2 , 6.25]) In [13]: x[0]=0 In [14]: x Out[14]: array([ 0. , 0.05, 0.1 , 0.15, 0.2 , 0.25, 0.3 , 0.35, 0.4 , 0.45, 0.5 , 0.55, 0.6 , 0.65, 0.7 , 0.75, 0.8 , 0.85, 0.9 , 0.95, 1. , 1.05, 1.1 , 1.15, 1.2 , 1.25, 1.3 , 1.35, 1.4 , 1.45, 1.5 , 1.55, 1.6 , 1.65, 1.7 , 1.75, 1.8 , 1.85, 1.9 , 1.95, 2. , 2.05, 2.1 , 2.15, 2.2 , 2.25, 2.3 , 2.35, 2.4 , 2.45, 2.5 , 2.55, 2.6 , 2.65, 2.7 , 2.75, 2.8 , 2.85, 2.9 , 2.95, 3. , 3.05, 3.1 , 3.15, 3.2 , 3.25, 3.3 , 3.35, 3.4 , 3.45, 3.5 , 3.55, 3.6 , 3.65, 3.7 , 3.75, 3.8 , 3.85, 3.9 , 3.95, 4. , 4.05, 4.1 , 4.15, 4.2 , 4.25, 4.3 , 4.35, 4.4 , 4.45, 4.5 , 4.55, 4.6 , 4.65, 4.7 , 4.75, 4.8 , 4.85, 4.9 , 4.95, 5. , 5.05, 5.1 , 5.15, 5.2 , 5.25, 5.3 , 5.35, 5.4 , 5.45, 5.5 , 5.55, 5.6 , 5.65, 5.7 , 5.75, 5.8 , 5.85, 5.9 , 5.95, 6. , 6.05, 6.1 , 6.15, 6.2 , 6.25]) In [15]: y=sin(x) In [16]: y Out[16]: array([ 0. , 0.04997917, 0.09983342, 0.14943813, 0.19866933, 0.24740396, 0.29552021, 0.34289781, 0.38941834, 0.43496553, 0.47942554, 0.52268723, 0.56464247, 0.60518641, 0.64421769, 0.68163876, 0.71735609, 0.75128041, 0.78332691, 0.8134155 , 0.84147098, 0.86742323, 0.89120736, 0.91276394, 0.93203909, 0.94898462, 0.96355819, 0.97572336, 0.98544973, 0.99271299, 0.99749499, 0.99978376, 0.9995736 , 0.99686503, 0.99166481, 0.98398595, 0.97384763, 0.9612752 , 0.94630009, 0.92895972, 0.90929743, 0.88736237, 0.86320937, 0.83689879, 0.8084964 , 0.7780732 , 0.74570521, 0.71147335, 0.67546318, 0.6377647 , 0.59847214, 0.55768372, 0.51550137, 0.47203054, 0.42737988, 0.38166099, 0.33498815, 0.28747801, 0.23924933, 0.19042265, 0.14112001, 0.09146464, 0.04158066, -0.00840725, -0.05837414, -0.10819513, -0.15774569, -0.20690197, -0.2555411 , -0.30354151, -0.35078323, -0.39714817, -0.44252044, -0.48678665, -0.52983614, -0.57156132, -0.61185789, -0.65062514, -0.68776616, -0.72318812, -0.7568025 , -0.78852525, -0.81827711, -0.8459837 , -0.87157577, -0.89498936, -0.91616594, -0.93505258, -0.95160207, -0.96577306, -0.97753012, -0.98684386, -0.993691 , -0.99805444, -0.99992326, -0.99929279, -0.99616461, -0.99054654, -0.98245261, -0.97190307, -0.95892427, -0.94354867, -0.92581468, -0.90576664, -0.88345466, -0.85893449, -0.83226744, -0.80352016, -0.77276449, -0.74007731, -0.70554033, -0.66923986, -0.63126664, -0.59171558, -0.55068554, -0.50827908, -0.46460218, -0.41976402, -0.37387666, -0.32705481, -0.2794155 , -0.23107779, -0.1821625 , -0.13279191, -0.0830894 , -0.03317922]) In [17]: In [18]: x+=1 In [19]: x Out[19]: array([ 1. , 1.05, 1.1 , 1.15, 1.2 , 1.25, 1.3 , 1.35, 1.4 , 1.45, 1.5 , 1.55, 1.6 , 1.65, 1.7 , 1.75, 1.8 , 1.85, 1.9 , 1.95, 2. , 2.05, 2.1 , 2.15, 2.2 , 2.25, 2.3 , 2.35, 2.4 , 2.45, 2.5 , 2.55, 2.6 , 2.65, 2.7 , 2.75, 2.8 , 2.85, 2.9 , 2.95, 3. , 3.05, 3.1 , 3.15, 3.2 , 3.25, 3.3 , 3.35, 3.4 , 3.45, 3.5 , 3.55, 3.6 , 3.65, 3.7 , 3.75, 3.8 , 3.85, 3.9 , 3.95, 4. , 4.05, 4.1 , 4.15, 4.2 , 4.25, 4.3 , 4.35, 4.4 , 4.45, 4.5 , 4.55, 4.6 , 4.65, 4.7 , 4.75, 4.8 , 4.85, 4.9 , 4.95, 5. , 5.05, 5.1 , 5.15, 5.2 , 5.25, 5.3 , 5.35, 5.4 , 5.45, 5.5 , 5.55, 5.6 , 5.65, 5.7 , 5.75, 5.8 , 5.85, 5.9 , 5.95, 6. , 6.05, 6.1 , 6.15, 6.2 , 6.25, 6.3 , 6.35, 6.4 , 6.45, 6.5 , 6.55, 6.6 , 6.65, 6.7 , 6.75, 6.8 , 6.85, 6.9 , 6.95, 7. , 7.05, 7.1 , 7.15, 7.2 , 7.25]) In [20]: x-=1 In [21]: x Out[21]: array([ 0. , 0.05, 0.1 , 0.15, 0.2 , 0.25, 0.3 , 0.35, 0.4 , 0.45, 0.5 , 0.55, 0.6 , 0.65, 0.7 , 0.75, 0.8 , 0.85, 0.9 , 0.95, 1. , 1.05, 1.1 , 1.15, 1.2 , 1.25, 1.3 , 1.35, 1.4 , 1.45, 1.5 , 1.55, 1.6 , 1.65, 1.7 , 1.75, 1.8 , 1.85, 1.9 , 1.95, 2. , 2.05, 2.1 , 2.15, 2.2 , 2.25, 2.3 , 2.35, 2.4 , 2.45, 2.5 , 2.55, 2.6 , 2.65, 2.7 , 2.75, 2.8 , 2.85, 2.9 , 2.95, 3. , 3.05, 3.1 , 3.15, 3.2 , 3.25, 3.3 , 3.35, 3.4 , 3.45, 3.5 , 3.55, 3.6 , 3.65, 3.7 , 3.75, 3.8 , 3.85, 3.9 , 3.95, 4. , 4.05, 4.1 , 4.15, 4.2 , 4.25, 4.3 , 4.35, 4.4 , 4.45, 4.5 , 4.55, 4.6 , 4.65, 4.7 , 4.75, 4.8 , 4.85, 4.9 , 4.95, 5. , 5.05, 5.1 , 5.15, 5.2 , 5.25, 5.3 , 5.35, 5.4 , 5.45, 5.5 , 5.55, 5.6 , 5.65, 5.7 , 5.75, 5.8 , 5.85, 5.9 , 5.95, 6. , 6.05, 6.1 , 6.15, 6.2 , 6.25]) In [22]: y Out[22]: array([ 0. , 0.04997917, 0.09983342, 0.14943813, 0.19866933, 0.24740396, 0.29552021, 0.34289781, 0.38941834, 0.43496553, 0.47942554, 0.52268723, 0.56464247, 0.60518641, 0.64421769, 0.68163876, 0.71735609, 0.75128041, 0.78332691, 0.8134155 , 0.84147098, 0.86742323, 0.89120736, 0.91276394, 0.93203909, 0.94898462, 0.96355819, 0.97572336, 0.98544973, 0.99271299, 0.99749499, 0.99978376, 0.9995736 , 0.99686503, 0.99166481, 0.98398595, 0.97384763, 0.9612752 , 0.94630009, 0.92895972, 0.90929743, 0.88736237, 0.86320937, 0.83689879, 0.8084964 , 0.7780732 , 0.74570521, 0.71147335, 0.67546318, 0.6377647 , 0.59847214, 0.55768372, 0.51550137, 0.47203054, 0.42737988, 0.38166099, 0.33498815, 0.28747801, 0.23924933, 0.19042265, 0.14112001, 0.09146464, 0.04158066, -0.00840725, -0.05837414, -0.10819513, -0.15774569, -0.20690197, -0.2555411 , -0.30354151, -0.35078323, -0.39714817, -0.44252044, -0.48678665, -0.52983614, -0.57156132, -0.61185789, -0.65062514, -0.68776616, -0.72318812, -0.7568025 , -0.78852525, -0.81827711, -0.8459837 , -0.87157577, -0.89498936, -0.91616594, -0.93505258, -0.95160207, -0.96577306, -0.97753012, -0.98684386, -0.993691 , -0.99805444, -0.99992326, -0.99929279, -0.99616461, -0.99054654, -0.98245261, -0.97190307, -0.95892427, -0.94354867, -0.92581468, -0.90576664, -0.88345466, -0.85893449, -0.83226744, -0.80352016, -0.77276449, -0.74007731, -0.70554033, -0.66923986, -0.63126664, -0.59171558, -0.55068554, -0.50827908, -0.46460218, -0.41976402, -0.37387666, -0.32705481, -0.2794155 , -0.23107779, -0.1821625 , -0.13279191, -0.0830894 , -0.03317922]) In [23]: plot(x,y) Out[23]: [] In [24]: x.shape Out[24]: (126,) In [25]: x.ndim Out[25]: 1 In [26]: x=arange(16) In [27]: x Out[27]: array([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) In [28]: x.reshape((2,2)) --------------------------------------------------------------------------- ValueError Traceback (most recent call last) /Users/stevel/wp/lecture/2012_01_Intro_Programming/lec6/ in () ValueError: total size of new array must be unchanged In [29]: x.reshape((4,4)) Out[29]: array([[ 0, 1, 2, 3], [ 4, 5, 6, 7], [ 8, 9, 10, 11], [12, 13, 14, 15]]) In [30]: xx=x.reshape((4,4)) In [31]: xx Out[31]: array([[ 0, 1, 2, 3], [ 4, 5, 6, 7], [ 8, 9, 10, 11], [12, 13, 14, 15]]) In [32]: xx.ndim Out[32]: 2 In [33]: xx.shape Out[33]: (4, 4) In [34]: xx+=1 In [35]: xx Out[35]: array([[ 1, 2, 3, 4], [ 5, 6, 7, 8], [ 9, 10, 11, 12], [13, 14, 15, 16]]) In [36]: a=arange(5) In [37]: b=arange(1,6) In [38]: a Out[38]: array([0, 1, 2, 3, 4]) In [39]: b Out[39]: array([1, 2, 3, 4, 5]) In [40]: a*b Out[40]: array([ 0, 2, 6, 12, 20]) In [41]: dot(a,b) Out[41]: 40 In [42]: a=matrix(a) In [43]: b=matrix(b) In [44]: a Out[44]: matrix([[0, 1, 2, 3, 4]]) In [45]: b Out[45]: matrix([[1, 2, 3, 4, 5]]) In [46]: a.shape Out[46]: (1, 5) In [47]: b.shape Out[47]: (1, 5) In [48]: b.reshape((5,1)) Out[48]: matrix([[1], [2], [3], [4], [5]]) In [49]: b=b.reshape((5,1)) In [50]: a Out[50]: matrix([[0, 1, 2, 3, 4]]) In [51]: b Out[51]: matrix([[1], [2], [3], [4], [5]]) In [52]: a*b Out[52]: matrix([[40]]) In [53]: b*a Out[53]: matrix([[ 0, 1, 2, 3, 4], [ 0, 2, 4, 6, 8], [ 0, 3, 6, 9, 12], [ 0, 4, 8, 12, 16], [ 0, 5, 10, 15, 20]]) In [54]: a=arange(50) In [55]: a Out[55]: array([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49]) In [56]: a(c>5) --------------------------------------------------------------------------- NameError Traceback (most recent call last) /Users/stevel/wp/lecture/2012_01_Intro_Programming/lec6/ in () NameError: name 'c' is not defined In [57]: a[c>5] KeyboardInterrupt In [57]: a[c>5] --------------------------------------------------------------------------- NameError Traceback (most recent call last) /Users/stevel/wp/lecture/2012_01_Intro_Programming/lec6/ in () NameError: name 'c' is not defined In [58]: c=a[c>5] --------------------------------------------------------------------------- NameError Traceback (most recent call last) /Users/stevel/wp/lecture/2012_01_Intro_Programming/lec6/ in () NameError: name 'c' is not defined In [59]: a[a>5] Out[59]: array([ 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49]) In [60]: xlabel("x") Out[60]: In [61]: ylabel("y") Out[61]: In [62]: plot(x,x) Out[62]: [] In [63]: clf() In [64]: plot(x,x) Out[64]: [] In [65]: