-
Notifications
You must be signed in to change notification settings - Fork 0
/
zscore.html
103 lines (94 loc) · 2.67 KB
/
zscore.html
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
<HTML>
<meta name="viewport" content="width=device-width, initial-scale=1">
<Head>
<script>
function GetZPercent(z)
{
//z == number of standard deviations from the mean
//if z is greater than 6.5 standard deviations from the mean
//the number of significant digits will be outside of a reasonable
//range
if ( z < -6.5)
return 0.0;
if( z > 6.5)
return 1.0;
var factK = 1;
var sum = 0;
var term = 1;
var k = 0;
var loopStop = Math.exp(-23);
while(Math.abs(term) > loopStop)
{
term = .3989422804 * Math.pow(-1,k) * Math.pow(z,k) / (2 * k + 1) / Math.pow(2,k) * Math.pow(z,k+1) / factK;
sum += term;
k++;
factK *= k;
}
sum += 0.5;
return sum;
}
function zconvert() {
zvalue = parseFloat(document.zcalc.zscore.value);
output = GetZPercent(zvalue);
document.zcalc.pvalue.value = output
var canvas = document.getElementById('myCanvas');
var context = canvas.getContext('2d');
context.clearRect(0, 0, canvas.width, canvas.height);
var imageObj = new Image();
imageObj.onload = function() {
context.drawImage(imageObj, 0, 0, 300, 300);
};
imageObj.src = 'normal_distribution.gif';
context.beginPath();
yvariable = 300 * output + 8;
context.moveTo(yvariable, 20);
context.lineTo(yvariable, 280);
context.strokeStyle = '#ff0000';
context.stroke();
}
</script>
<STYLE>
.inputbox {
width: 100px;
border: 1px solid #CCC;
height: 30px;
font-size: 12pt;
}
</STYLE>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-57854391-1', 'auto');
ga('send', 'pageview');
</script></head>
<BODY>
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- responsive -->
<ins class="adsbygoogle"
style="display:block"
data-ad-client="ca-pub-7620137999744720"
data-ad-slot="5778750897"
data-ad-format="auto"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
<BR>
<Script src="menu.js"></Script><BR>
<form name="zcalc">
Z-Score Calculator<BR>
<Table>
<TR>
<TD>Z-score</TD>
<TD><Input type="text" name="zscore" value="0"><Input type="button" value="calculate" onclick="zconvert()"></TD>
</TR>
<TR>
<TD>Probability</TD>
<TD><Input type="text" name="pvalue" value="0"></TD>
</TR>
</Table>
</Form>
<canvas id="myCanvas" width="300" height="300"></canvas>
</BODY>
</HTML>