Posted By

jatkins on 05/10/10


Tagged

math Maths standarddeviation


Versions (?)

Standard Deviation Calculator


 / Published in: HTML
 

Licensed under CC-by-2.0.

  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
  3. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  4. <title>Standard deviation calculator</title>
  5. <style type="text/css">
  6. <!--
  7. body {
  8. font: 80% Arial, Helvetica, sans-serif;
  9. }
  10.  
  11. span {
  12. display: block;
  13. }
  14. -->
  15. </style>
  16. <script type="text/javascript">
  17. <!--
  18. var i = 0, fieldCount = 0, mean = 0, deviation = 0;
  19.  
  20. function get(elmnt) {
  21. return document.getElementById(elmnt);
  22. }
  23.  
  24. function add_field() {
  25. newFieldSpan = document.createElement('span');
  26. newFieldSpan.id = 'spanField'+fieldCount.toString();
  27. newField = document.createElement('input');
  28. newField.type = 'text';
  29. newField.value = '';
  30. newField.id = 'txtValue'+fieldCount;
  31. newFieldSpan.appendChild(newField);
  32. deleteButton = document.createElement('input');
  33. deleteButton.type = 'button';
  34. deleteButton.value = 'Delete'
  35. deleteButton.title = 'spanField'+fieldCount.toString();
  36. deleteButton.onclick = function() { get('divFields').removeChild(get(this.title.toString())); fieldCount--; };
  37. newFieldSpan.appendChild(newField);
  38. newFieldSpan.appendChild(deleteButton);
  39. get('divFields').appendChild(newFieldSpan);
  40. fieldCount++;
  41. }
  42.  
  43. function calculate() {
  44. mean = 0;
  45. deviation = 0;
  46. for(i=0;i<fieldCount;i++) {
  47. mean += parseFloat(get('divFields').childNodes[i].childNodes[0].value);
  48. }
  49. mean /= fieldCount;
  50. for(i=0;i<fieldCount;i++) {
  51. deviation += Math.pow(parseFloat(get('divFields').childNodes[i].childNodes[0].value) - mean, 2);
  52. }
  53. deviation = Math.sqrt(deviation/(fieldCount-1));
  54. get('divResults').innerHTML = '<h2>Standard Deviation: '+deviation.toString()+'</h2>';
  55. }
  56. -->
  57. </script>
  58. </head>
  59. <div>
  60. <h1>Standard deviation calculator</h1>
  61. <input type="button" value="Add Field" onclick="add_field();" />
  62. <div id="divFields"></div>
  63. <input type="submit" value="Calculate" onclick="calculate();" />
  64. </div>
  65. <div id="divResults">
  66. </div>
  67. </body>
  68. </html>

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: geeknick1 on November 4, 2011

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

Posted By: geeknick1 on November 4, 2011

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

You need to login to post a comment.