This repository was archived by the owner on Jun 3, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstdNormDist100pt.js
More file actions
42 lines (42 loc) · 3.04 KB
/
stdNormDist100pt.js
File metadata and controls
42 lines (42 loc) · 3.04 KB
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
/*stdNormDist100pt.js
* copyright (c) 2016 Yuji SODE <yuji.sode@gmail.com>
*/
//it draws 100 points: [-4,+4] graph data of the standard normal distribution.
//data was calculated with gnuplot version 4.6 patchlevel 4.
function _stdNormDist100pt(){
var slf=this.window,cvsId,c,d,n=0,i=1,w0=0,h0=0,dw=0,dh=0;
cvsId=slf.prompt('canvas id?');
c=slf.document.getElementById(cvsId).getContext('2d');
if(!c){throw 'the id/canvas tag is undefined';}
w0=c.canvas.width,h0=c.canvas.height;
dw=w0*0.01,dh=h0/0.3989422804014327;
d=xy(),n=d.length;
c.clearRect(0,0,w0,h0);
c.strokeStyle='rgba(0,0,255,1)',c.lineWidth=1.0;
//drawing graph
c.beginPath(),c.moveTo(0,h0-d[0][1]*dh);
while(i<n){c.lineTo(i*dw,h0-d[i][1]*dh),i+=1;}
c.stroke();
//====== data calculated with GNUPLOT Version 4.6 patchlevel 4 ======
//it returns 100 points: [-4,+4] graph data of the standard normal distribution.
function xy(){
return [
[-4,0.00013383],[-3.91919,0.000184295],[-3.83838,0.000252138],[-3.75758,0.00034271],[-3.67677,0.000462785],[-3.59596,0.000620862],
[-3.51515,0.000827515],[-3.43434,0.00109577],[-3.35354,0.00144155],[-3.27273,0.00188409],[-3.19192,0.00244646],[-3.11111,0.00315602],
[-3.0303,0.00404487],[-2.94949,0.00515031],[-2.86869,0.00651518],[-2.78788,0.00818811],[-2.70707,0.0102236],[-2.62626,0.0126821],
[-2.54545,0.0156293],[-2.46465,0.0191361],[-2.38384,0.0232772],[-2.30303,0.0281302],[-2.22222,0.0337737],[-2.14141,0.0402854],
[-2.06061,0.0477399],[-1.9798,0.0562056],[-1.89899,0.0657418],[-1.81818,0.0763955],[-1.73737,0.0881979],[-1.65657,0.101161],
[-1.57576,0.115274],[-1.49495,0.130501],[-1.41414,0.146778],[-1.33333,0.16401],[-1.25253,0.182073],[-1.17172,0.200809],
[-1.09091,0.220033],[-1.0101,0.239527],[-0.929293,0.259051],[-0.848485,0.278343],[-0.767677,0.297125],[-0.686869,0.31511],
[-0.606061,0.332009],[-0.525253,0.347537],[-0.444444,0.361424],[-0.363636,0.373419],[-0.282828,0.383301],[-0.20202,0.390884],
[-0.121212,0.396022],[-0.040404,0.398617],[0.040404,0.398617],[0.121212,0.396022],[0.20202,0.390884],[0.282828,0.383301],
[0.363636,0.373419],[0.444444,0.361424],[0.525253,0.347537],[0.606061,0.332009],[0.686869,0.31511],[0.767677,0.297125],
[0.848485,0.278343],[0.929293,0.259051],[1.0101,0.239527],[1.09091,0.220033],[1.17172,0.200809],[1.25253,0.182073],
[1.33333,0.16401],[1.41414,0.146778],[1.49495,0.130501],[1.57576,0.115274],[1.65657,0.101161],[1.73737,0.0881979],
[1.81818,0.0763955],[1.89899,0.0657418],[1.9798,0.0562056],[2.06061,0.0477399],[2.14141,0.0402854],[2.22222,0.0337737],
[2.30303,0.0281302],[2.38384,0.0232772],[2.46465,0.0191361],[2.54545,0.0156293],[2.62626,0.0126821],[2.70707,0.0102236],
[2.78788,0.00818811],[2.86869,0.00651518],[2.94949,0.00515031],[3.0303,0.00404487],[3.11111,0.00315602],[3.19192,0.00244646],
[3.27273,0.00188409],[3.35354,0.00144155],[3.43434,0.00109577],[3.51515,0.000827515],[3.59596,0.000620862],[3.67677,0.000462785],
[3.75758,0.00034271],[3.83838,0.000252138],[3.91919,0.000184295],[4,0.00013383]
];}
}