{VERSION 5 0 "SUN SPARC SOLARIS" "5.0" } {USTYLETAB {CSTYLE "Maple Input" -1 0 "Courier" 0 1 255 0 0 1 0 1 0 0 1 0 0 0 0 1 }{CSTYLE "2D Math" -1 2 "Times" 0 1 0 0 0 0 0 0 2 0 0 0 0 0 0 1 }{CSTYLE "2D Comment" 2 18 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 } {CSTYLE "" -1 256 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 257 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 258 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 259 "" 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 1 }{CSTYLE "" -1 260 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 } {CSTYLE "" -1 261 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 }{CSTYLE "" -1 263 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 }{CSTYLE "" -1 264 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 }{CSTYLE "" -1 265 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 }{CSTYLE "" -1 268 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 } {CSTYLE "" -1 269 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 }{CSTYLE "" -1 270 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 }{CSTYLE "" -1 271 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 }{CSTYLE "" -1 272 "" 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 273 "" 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 } {CSTYLE "" -1 274 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 }{PSTYLE "Normal " -1 0 1 {CSTYLE "" -1 -1 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "Maple Output" 0 11 1 {CSTYLE "" -1 -1 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 }3 3 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "Maple Plot" -1 256 1 {CSTYLE "" -1 -1 "Times" 1 12 0 0 0 1 2 2 2 2 2 2 1 1 1 1 }1 1 0 0 0 0 1 0 1 0 2 2 0 1 }{PSTYLE "Normal " -1 257 1 {CSTYLE "" -1 -1 "Times" 1 12 0 0 0 1 2 2 2 2 2 2 1 1 1 1 } 3 1 0 0 0 0 1 0 1 0 2 2 0 1 }{PSTYLE "Maple Output" -1 258 1 {CSTYLE " " -1 -1 "Times" 1 12 0 0 0 1 2 2 2 2 2 2 1 1 1 1 }1 3 0 0 0 0 1 0 1 0 2 2 0 1 }{PSTYLE "" 0 259 1 {CSTYLE "" -1 -1 "" 1 14 0 0 0 0 0 0 0 0 0 0 0 0 0 0 }3 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "" 0 260 1 {CSTYLE "" -1 -1 "" 1 14 0 0 0 0 0 0 0 0 0 0 0 0 0 0 }3 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "" 0 261 1 {CSTYLE "" -1 -1 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 }2 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }} {SECT 0 {PARA 259 "" 0 "" {TEXT -1 51 "The method of least squares fo r linear regression," }}{PARA 260 "" 0 "" {TEXT -1 34 "with applicatio n to power law fits" }}{PARA 261 "" 0 "" {TEXT -1 11 "Access 2009" }} {PARA 0 "" 0 "" {TEXT -1 53 "We'll let Maple check the examples we wor ked by hand:" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 29 "restart: #c lear old commands" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 48 "with(p lots): #load plotting package of commands" }}}{EXCHG {PARA 0 "> " 0 " " {MPLTEXT 1 0 52 "with(stats): #load statistics package of command s" }}}{PARA 0 "" 0 "" {TEXT -1 107 "Notice that the following commands use a lot of parenthesis, so be careful when you try your own example s. " }}{PARA 0 "" 0 "" {TEXT 256 9 "Example 1" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 25 "XY1:=[[0,1],[2,2],[4,1]]:" }}}{EXCHG {PARA 0 "> \+ " 0 "" {MPLTEXT 1 0 42 "PlotXY1:=pointplot(XY1):\ndisplay(PlotXY1);" } }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 247 "fit[leastsquare[[X,Y]]]([ [0,2,4],[1,2,1]]);\n #syntax: [X,Y] says we are calling the coords \+ \"X\" and \"Y\".\n #what follws is the list of \"X\" values, and the n the\n #corresponding \"Y\" values....\n # so the point s are [0,1],[2,2],[4,1] " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 171 "Line1:=plot(4/3, X=-1..5,Y=-1..3, \+ color=black):\n #I picked a slightly larger X-Y box than the points we re in\ndisplay(\{Line1,PlotXY1\}, title=`Example 1 least squares fit`) ;" }}}{PARA 0 "" 0 "" {TEXT 257 9 "Example 2" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 25 "XY2:=[[0,3],[1,5],[2,5]]:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 42 "PlotXY2:=pointplot(XY2):\ndisplay(PlotXY2);" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 43 "fit[leastsquare[[X,Y]]]([[0, 1,2],[3,5,5]]);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 115 "Line2:= plot(10/3 + X, X=-1..3,Y=-1..6, color=black):\ndisplay(\{Line2,PlotXY2 \}, title=`Example 2 least squares fit`);" }}}{PARA 0 "" 0 "" {TEXT 258 9 "Example 3" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 31 "XY3:=[[0 ,3],[1,5],[2,6],[3,7]]:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 42 " PlotXY3:=pointplot(XY3):\ndisplay(PlotXY3);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 47 "fit[ leastsquare[[X,Y]]]([[0,1,2,3],[3,5,6,7]]);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 125 "Line3:=plot(33/10 + (13/10) *X, X=-1..4,Y=-1..8, \+ color=black):\ndisplay(\{Line3,PlotXY3\}, title=`Example 3 least squar es fit`);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{PARA 0 " " 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 " " {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT 261 31 "How do you test for po wer laws?" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 190 "What if our points don't lie in a straight line? What if it look s like it should be a quadratic function or even a square root functio n? In other words, we want to see if there is a power " }{TEXT 272 1 "m" }{TEXT -1 32 " and a proportionality constant " }{TEXT 273 1 "b" } {TEXT -1 20 " so that the formula" }}{PARA 257 "" 0 "" {XPPEDIT 18 0 " y = b*x^m;" "6#/%\"yG*&%\"bG\"\"\")%\"xG%\"mGF'" }{TEXT -1 0 "" }} {PARA 0 "" 0 "" {TEXT -1 36 "effectively mirrors the real data. " } {TEXT 260 65 "Taking (e.g. natural) logarithms of the proposed power l aw yields" }}{PARA 257 "" 0 "" {XPPEDIT 18 0 "ln(y) = ln(b)+m*ln(x);" "6#/-%#lnG6#%\"yG,&-F%6#%\"bG\"\"\"*&%\"mGF,-F%6#%\"xGF,F," }{TEXT -1 1 "." }}{PARA 0 "" 0 "" {TEXT -1 16 "So, if we write " }{XPPEDIT 18 0 "Y = ln(y);" "6#/%\"YG-%#lnG6#%\"yG" }{TEXT -1 7 " and " }{XPPEDIT 18 0 "X = ln(x);" "6#/%\"XG-%#lnG6#%\"xG" }{TEXT -1 3 ", " }{XPPEDIT 18 0 "B = ln(b);" "6#/%\"BG-%#lnG6#%\"bG" }{TEXT -1 59 ", this becomes the equation of a line in the new variables " }{XPPEDIT 18 0 "X;" "6# %\"XG" }{TEXT -1 5 " and " }{XPPEDIT 18 0 "Y;" "6#%\"YG" }{TEXT -1 1 " :" }}{PARA 257 "" 0 "" {XPPEDIT 18 0 "Y = mX+B;" "6#/%\"YG,&%#mXG\"\" \"%\"BGF'" }{TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 5 "Thus," }{TEXT 263 1 " " }{TEXT 264 207 "in order for there to be a power law for the original data, the ln-ln data should (approximately) satisfy the equa tion of a line, and vise verse. If we get a good line fit to the ln-l n data, then the slope " }{XPPEDIT 18 0 "m" "6#%\"mG" }{TEXT 270 75 " \+ of this line is the power relating the original data, and the exponent ial " }{XPPEDIT 18 0 "exp(B);" "6#-%$expG6#%\"BG" }{TEXT 265 8 " of th e " }{XPPEDIT 18 0 "Y" "6#%\"YG" }{TEXT 271 43 "-intercept is the prop ortionality constant " }{XPPEDIT 18 0 "b" "6#%\"bG" }{TEXT 268 26 " in the original relation " }{XPPEDIT 18 0 "y = b*x^m" "6#/%\"yG*&%\"bG\" \"\")%\"xG%\"mGF'" }{TEXT 269 3 ". " }{TEXT -1 161 "With real data it is not too hard to see if the ln-ln data is well approximated by a li ne, in which case the original data is well-approximated by a power la w. " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT 274 21 " Astronomical example:" }{TEXT -1 534 " As you may know, Isaac Newton \+ was motivated by Kepler's (observed) Laws of planetary motion to disco ver the notions of velocity and acceleration, i.e. differential calcul us, along with the inverse square law of planetary acceleration around the sun.....from which he deduced the concepts of mass and force, and that the universal inverse square law for gravitatonal attraction wa s the ONLY force law depending only on distance between objects, which was consistent with Kepler's observations! Kepler's three observatio ns were that" }}{PARA 0 "" 0 "" {TEXT -1 80 "(1) Planets orbit the su n in ellipses, with the sun at one of the ellipse foci." }}{PARA 0 "" 0 "" {TEXT -1 119 "(2) A planet sweeps out equal angles from the sun, in equal time intervals, independently of where it is in its orbit." }}{PARA 0 "" 0 "" {TEXT -1 119 "(3) The square of the period of a pla netary orbit is directly proportional to the cube of the orbit's semi- major axis." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 115 "So, for roughly circular orbits, Keplers third law translates \+ to the statement that the period is proportional to " }{XPPEDIT 18 0 "R^1.5;" "6#*$)%\"RG$\"#:!\"\"\"\"\"" }{TEXT -1 93 ", where R is the a pproximate radius. Let's see if that's consistent with the following \+ data:" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 105 "Planet mean distance R from sun \+ Orbital period T" }}{PARA 0 "" 0 "" {TEXT -1 96 " \+ (in astronomical units where 1=dist to earth) \+ (in earth years)" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 " " 0 "" {TEXT -1 109 "Mercury 0.38 7 0.241" }}{PARA 0 "" 0 "" {TEXT -1 114 "Earth \+ 1. 1." }}{PARA 0 "" 0 "" {TEXT -1 113 "Jupiter \+ 5.20 \+ 11.86" }}{PARA 0 "" 0 "" {TEXT -1 109 "Uranus \+ 19.18 \+ 84.0" }}{PARA 0 "" 0 "" {TEXT -1 112 "Pluto \+ 39.53 \+ 248.5" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }{TEXT 259 0 "" } {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 45 "restart:with (linalg):with(plots):with(stats):" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 98 "Rs:=[0.387,1.,5.20,19.18,39.53];\nTs:=[.241,1.,11.86, 84.0,248.5];\npts:=[seq([Rs[i],Ts[i]],i=1..5)];" }}}{EXCHG {PARA 0 "> \+ " 0 "" {MPLTEXT 1 0 36 "data:=pointplot(pts):\ndisplay(data);" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 92 "lnRs:=map(ln,Rs); #get ln-l n data\nlnTs:=map(ln,Ts);\nlnpts:=[seq([lnRs[i],lnTs[i]],i=1..5)];" }} }{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 46 "lnlndata:=pointplot(lnpts): \ndisplay(lnlndata);" }}}{PARA 0 "" 0 "" {TEXT -1 109 "Notice the ln-l n plot really does seem close to a line! So maybe there is a power la w for the original data:" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 69 " fit[leastsquare[[lnR,lnT]]]([ lnRs,lnTs]);#this is the bizarre syntax " }}}{PARA 256 "" 0 "" {TEXT -1 65 "We can paste in the equation of th e line and see how well we did." }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 134 "line:=plot(.4868929851e-3+1.499816412*lnR, lnR=-2..6,lnT=-2.. 6,\n color=black):\ndisplay(\{lnlndata,line\}, title=`least squares \+ fit`);\n" }}}{PARA 0 "" 0 "" {TEXT -1 70 "Finally, we can go back from the least squares line fit to a power law" }}{EXCHG {PARA 0 "> " 0 " " {MPLTEXT 1 0 75 "m:=1.499816412; #power\nb:=exp(0.0004868929851); # proportionality constant\n" }}}{PARA 0 "" 0 "" {TEXT -1 40 "Notice in \+ the command lines below how to" }}{PARA 0 "" 0 "" {TEXT -1 20 " (i) make a title" }}{PARA 0 "" 0 "" {TEXT -1 81 " (ii) get the axes la beled \"g\" and \"c\" for number of genes and number of cells" }} {PARA 0 "" 0 "" {TEXT -1 210 " (iii) get the display to include app ropriate ranges - to contain all our data\n (iv) first create a pic ture of the power function, and then display its graph along with the \+ original gene/cell data points." }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 52 "powerplot:=plot(b*R^m,R=0..50,T=0..300,color=black):" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 194 "display(\{powerplot,data\}, title=\n `power law for planetary period as a function of radius`);\n #by calling the variables R and T, and giving their ranges, I\n#get Ma ple to label the axes as I want\n" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}} {PARA 11 "" 1 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}} {MARK "72 0 0" 0 }{VIEWOPTS 1 1 0 1 1 1803 1 1 1 1 }{PAGENUMBERS 0 1 2 33 1 1 }