/ Published in: HTML
Licensed under CC-by-2.0.
Expand |
Embed | Plain Text
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <style type="text/css"> <!-- body { font: 80% Arial, Helvetica, sans-serif; } span { display: block; } --> </style> <script type="text/javascript"> <!-- var i = 0, fieldCount = 0, mean = 0, deviation = 0; function get(elmnt) { return document.getElementById(elmnt); } function add_field() { newFieldSpan = document.createElement('span'); newFieldSpan.id = 'spanField'+fieldCount.toString(); newField = document.createElement('input'); newField.type = 'text'; newField.value = ''; newField.id = 'txtValue'+fieldCount; newFieldSpan.appendChild(newField); deleteButton = document.createElement('input'); deleteButton.type = 'button'; deleteButton.value = 'Delete' deleteButton.title = 'spanField'+fieldCount.toString(); deleteButton.onclick = function() { get('divFields').removeChild(get(this.title.toString())); fieldCount--; }; newFieldSpan.appendChild(newField); newFieldSpan.appendChild(deleteButton); get('divFields').appendChild(newFieldSpan); fieldCount++; } function calculate() { mean = 0; deviation = 0; for(i=0;i<fieldCount;i++) { mean += parseFloat(get('divFields').childNodes[i].childNodes[0].value); } mean /= fieldCount; for(i=0;i<fieldCount;i++) { deviation += Math.pow(parseFloat(get('divFields').childNodes[i].childNodes[0].value) - mean, 2); } deviation = Math.sqrt(deviation/(fieldCount-1)); get('divResults').innerHTML = '<h2>Standard Deviation: '+deviation.toString()+'</h2>'; } --> </script> </head> <body> <div> <input type="button" value="Add Field" onclick="add_field();" /> <input type="submit" value="Calculate" onclick="calculate();" /> </div> <div id="divResults"> </div> </body> </html>
Comments
Subscribe to comments
You need to login to post a comment.

Steps for Standard Deviation Step 1 : Use formula for standard deviation, σ = √[(1/N)Σi(xi-μ)2].
Step 2 : Where σ - the standard deviation N - number of data points ; xi - the random variable where i takes values from 1 to N ;
Step 3 : μ- the mean of the data set; Then write the final answer for σ .
if you any large problem then i will suggest to use Standard Deviation Calculator Online
Steps for Standard Deviation Step 1 : Use formula for standard deviation, σ = √[(1/N)Σi(xi-μ)2].
Step 2 : Where σ - the standard deviation N - number of data points ; xi - the random variable where i takes values from 1 to N ;
Step 3 : μ- the mean of the data set; Then write the final answer for σ .
if you any large problem then i will suggest to use Standard Deviation Calculator Online