plot summary:
[Machine Xiao Wei], accompanied by [engineer Ah Wei], entered the middle of the end of Dan's cultivation,
The goal of this time to cultivate is [statistics].
Drama Start:
Star Calendar April 12, 2016 16:00:33, the Milky Way Galaxy Earles the Chinese Empire Jiangnan Line province.
[Engineer Ah Wei] is studying [statistics] with [machine Xiao Wei].
Xiao Wei thought for a moment and made such a tool to take a random sample:
<span style= "FONT-SIZE:18PX;" >>>> ================================ RESTART ================================>>> [1, 2, 3, 4, 5, 6, 7, 8, 9, 10][10, 1, 9]>>> ================================ RESTART ================================>> > [1, 2, 3, 4, 5, 6, 7, 8, 9, 10][5, 4, 8] #从N个样本中抽取n个样本def sample (n, N): a = List (range (1, n+1)); Print (a); Random.shuffle (a); return a[0:n];if __name__ = = ' __main__ ': print (sample (3));</span>
Still can play a play.
<span style= "FONT-SIZE:18PX;" >if (1) {var config = new plotconfiguration (); Config.init (); Config.setpreference (); var r =; Config.setsector (1,1,1,1); Config.graphpaper2d (0, 0, R); Config.axis2d (0, 0,180); var stat = new statistic (); var data = [4,8,15,22,25,14,6,4,2]; var text = []; Initialize each set of frequencies //0-60-year-old, 5-year-old group for (var i = 0; i < 5; i+=0.5) { Text.push (i.tofixed (1)); } Stat.init (data, ' monthly water consumption (t) ', ' number ', 1); Stat.histogram (text, 0, 0); } </span>
<span style= "FONT-SIZE:18PX;" >if (1) {var config = new plotconfiguration (); Config.init (); Config.setpreference (); var r = 20; Config.setsector (1,1,1,1); Config.graphpaper2d (0, 0, R); Config.axis2d (0, 0,180); var stat = new statistic (); var data = [4,8,15,22,25,14,6,4,2]; for (var i = 0; i < data.length; i++) {data[i]/=100;} var text = []; Initialize each group for (var i = 0; i < 5; i+=0.5) {Text.push (i.tofixed (1)); } stat.init (data, ' monthly water consumption (t) ', ' frequency ', 1); Stat.ratehistogram (text, 0, 0); }//frequency distribution Histogram This.ratehistogram = function (Lablearray, Xoffset, Yoffset, ymin, yMax) {Lablearray = Lablearray? Lablearray: [];var lables = Lablearray.length;xoffset = Xoffset? Xoffset:0;yoffset = Yoffset? Yoffset:0;var Colorarray = [' Red ', ' orange ', ' #0088FF ', ' green ', ' cyan ', ' Blue ', ' #FF00FF ', ' #FF8844 ', ' Purple '];var colo rs = Colorarray.length;var height = 380, Width = 580;plot.save (). Translate (xoffset+60, yoffset+50);p lot.setlinewidth (2) . setTeXtalign (' right '); var max = YMax? YMax:this.max (); var min = ymin? ymin:0; The maximum value of the last 0 approximate number, such as the maximum value of 25, the most suitable approximate number is 30var dy = Math.Round ((max-min)/10*100)/100;var size = This.size (); var perh = Math.Round ((height-100)/10); var perw = Math.Round ((width-100)/(size+2)),//width and height boundary var wbound = (size+2) *perw, Hbound = 10*perh;plot.setlinewidth (5). s Trokerect (0, 0, Wbound, hbound); this.axis2d (0, Hbound, wbound+20, hbound+20, This.xlabel, This.ylabel); Plot.setlinewidth (2); var count = 0;for (var i = hbound; I >-1; i-= perh) {plot.filltext ((min+dy*count). toFixed (2), 10 , i+10, count++;if (i > 0) {plot.beginpath (). MoveTo (0, I). LineTo (Wbound, i). Closepath (). stroke ();} for (var i = 0; i < size+2; i++) {Plot.beginpath (). MoveTo (i*perw, 0). LineTo (I*perw, Hbound). Closepath (). stroke (); var xpos, xpos2;for (var i = 0; i < size; i++) {var h =-(this.statisticalsample[i]-min)/dy*perh;xpos = perw* (1+i); xpo S2 = xpos + 0.5*perw;//for groups with a value of 0, do not take more action if (H < 0) {Plot.setfillstyle (colorarray[i%cOlors]); Plot.fillrect (perw* (1+i), Hbound, Perw, h); if (i = = 0) {xpos + = 0.75*perw;} else {xpos + = 0.5*perw;} Plot.setfillstyle (' Blue ');p Lot.filltext (this.statisticalsample[i].tostring (), xpos, h+hbound-5, 100);} Plot.setfillstyle (' Blue ');p lot.settextalign (' center '), if (I < lables) {Plot.filltext (lablearray[i], xpos2-0.5* Perw, hbound+30, 100); }//adds the last callout of the x-axis if (i = = size-1) {var n1 = parsefloat (Lablearray[i]); var n2 = parsefloat (lablearray[i-1]); var n3 = (2*N1-N2) var s;if (Math.Abs (N3-math.round (n3)) <0.001) {s = n3.tofixed (0);} else {s = n3.tofixed (1);} Plot.filltext (S, Xpos2+0.5*perw, hbound+30, 100); }//plot.filltext (this.statisticalsample[i].tofixed (0), Xpos2, hbound+40, 100); } plot.restore ();} </span>
<span style= "FONT-SIZE:18PX;" >//a set of points if (1) {var r = 20; Config.setsector (1,1,1,1); Config.graphpaper2d (0, 0, R); Config.axis2d (0, 0,180); Axis set var ScaleX = 2*r, ScaleY = 2*r; var SpaceX = ten, SpaceY = 10; var XS = -10, XE = 80; var YS = -10, YE = 50; Config.axisspacing (XS, XE, SpaceX, ScaleX, ' X '); Config.axisspacing (YS, YE, SpaceY, ScaleY, ' Y '); var x=[23,27,39,41,45,49,50,53,54,56,57,58,60,61], y=[9.5,17.8,21.2,25.9,27.5,26.3,28.2,29.6,30.2,31.4,30. 8,33.5,35.2,34.6]; var array = []; var size = X.length; for (var i = 0; i < size; i++) {Array.push ([x[i], y[i]]); } var transform = new transform (); var tmp = []; Array = Transform.scale (tRansform.translate (array, 0, 0), Scalex/spacex, Scaley/spacey); TMP = [].concat (array); Shape.pointdraw (TMP, ' green '); TMP = [].concat (array); Shape.multilinedraw (tmp, ' #CCFF22 '); }</span>
To fit, this is the formula with the least squares:
<span style= "FONT-SIZE:18PX;" >>>> x= [9.5, 17.8, 21.2, 25.9, 27.5, 26.3, 28.2, 2, 61]y=, Max, si, si, si, si, si, si 9.6, 30.2, 31.4, 30.8, 33.5, 35.2, 34.6] fit result: y = 0.57648 x + -0.44780, r= 0.97074def linefit (x, y): N = Flo at (Len (x)) sx,sy,sxx,syy,sxy=0,0,0,0,0 for I in Range (0,int (N)): SX + = x[i] sy + y[i] Sxx + = X[i]*x[i] Syy + y[i]*y[i] Sxy + = x[i]*y[i] A = (sy*sx/n-sxy)/(sx*sx/n-sxx) b = (SY-A*SX)/n r = ABS (SY*SX/N-SXY)/math.sqrt ((sxx-sx*sx/n) * (syy-sy*sy/n)) return A,b,r def tmp (): x=[ 23,27,39,41,45,49,50,53,54,56,57,58,60,61]; y=[9.5,17.8,21.2,25.9,27.5,26.3,28.2,29.6,30.2,31.4,30.8,33.5,35.2,34.6]; A,b,r=linefit (x, y) print ("x=", x) print ("y=", y) print ("fit result: Y =%10.5f X +%10.5f, r=%10.5f"% (a,b,r)) </span>
Results:
<span style= "FONT-SIZE:18PX;" > if (1) {var r = 20; Config.setsector (1,1,1,1); Config.graphpaper2d (0, 0, R); Config.axis2d (0, 0,180); Axis set var ScaleX = 2*r, ScaleY = 2*r; var SpaceX = ten, SpaceY = 10; var XS = -10, XE = 80; var YS = -10, YE = 50; Config.axisspacing (XS, XE, SpaceX, ScaleX, ' X '); Config.axisspacing (YS, YE, SpaceY, ScaleY, ' Y '); var x=[23,27,39,41,45,49,50,53,54,56,57,58,60,61], y=[9.5,17.8,21.2,25.9,27.5,26.3,28.2,29.6,30.2,31.4,30. 8,33.5,35.2,34.6]; var array = []; var size = X.length; for (var i = 0; i < size; i++) {Array.push ([x[i], y[i]]); } var transform = new transform (); var tmp = []; Array = Transform.scale (transform.Translate (array, 0, 0), Scalex/spacex, Scaley/spacey); TMP = [].concat (array); Shape.pointdraw (TMP, ' green '); array = []; for (var i = 0; i < size; i++) {Array.push ([x[i], Taskfun (X[i])]); } array = Transform.scale (transform.translate (array, 0, 0), Scalex/spacex, Scaley/spacey); TMP = [].concat (array); Shape.multilinedraw (TMP, ' red '); Plot.setfillstyle (' Blue ');p lot.filltext (' fit result: y = 0.57648 x-0.44780 ',-270,-170, 200); }}function Taskfun (x) {return 0.57648*x-0.44780;} </span>
The diligent little shopkeeper, Xiao Wei decided to make a good calculation of his data.
<span style= "FONT-SIZE:18PX;" >>>> x= [ -5, 0, 4, 7, 156, 150,, 132, 128, 130, 116, 104, 89, 93,] fitting result: Y. = -2.35170 x + 147.76710, r= 0.98113//a set of points if (1) {var r = 20; Config.setsector (1,1,1,1); Config.graphpaper2d (0, 0, R); Config.axis2d (0, 0,180); Axis set var ScaleX = 2*r, ScaleY = 2*r; var SpaceX = ten, SpaceY = 50; var XS = -10, XE = 50; var YS = -10, YE = 200; Config.axisspacing (XS, XE, SpaceX, ScaleX, ' X '); Config.axisspacing (YS, YE, SpaceY, ScaleY, ' Y '); var x=[-5, 0, 4, 7, 150, 132, 128, 130], y=[156, 116, 104, 89, 93, 76, 54,; var array = []; var size = X.length; for (var i = 0; i < size; i++) {Array.push ([x[i], y[I]]); } var transform = new transform (); var tmp = []; Array = Transform.scale (transform.translate (array, 0, 0), Scalex/spacex, Scaley/spacey); TMP = [].concat (array); Shape.pointdraw (TMP, ' green '); array = []; for (var i = 0; i < size; i++) {Array.push ([x[i], Taskfun (X[i])]); } array = Transform.scale (transform.translate (array, 0, 0), Scalex/spacex, Scaley/spacey); TMP = [].concat (array); Shape.multilinedraw (TMP, ' red '); Plot.setfillstyle (' Blue ');p lot.filltext (' fit result: y = -2.35170 x + 147.76710 ',-270,-170, 300); }if (0) {var config = new plotconfiguration (); Config.init (); Config.setpreference (); var r = 20; Config.setsector (1,1,1,1); Config.graphpaper2d (0, 0, R); Config.axis2d (0, 0,180); var x=[-5, 0, 4, 7, 156, 150, 132, 128, 130, (+); 116, 104, 89, 93, 76, 54]; var stat = new statistic (); var data = Y; var text = []; Horizontal for (var i = 0; i < x.length; i++) {Text.push (x[i].tofixed (0)); } stat.init (data, ' temperature ', ' sell hot drink (cup) ', 1); Stat.barchart (text, 0, 0); }}function Taskfun (x) {return-2.35170*x + 147.76710;} </span>
It seems that [people challenge the teacher] Also think this is the answer.
The end of this section, to know how to funeral, please see tell.
[ab initio math] section 175th statistics