{"id":1349,"date":"2022-03-03T07:15:59","date_gmt":"2022-03-03T07:15:59","guid":{"rendered":"https:\/\/mdr.foobrdigital.com\/?p=1349"},"modified":"2022-03-03T07:15:59","modified_gmt":"2022-03-03T07:15:59","slug":"calculate-standard-deviation","status":"publish","type":"post","link":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/2022\/03\/03\/calculate-standard-deviation\/","title":{"rendered":"Calculate Standard Deviation"},"content":{"rendered":"\n<p>This program calculates the standard deviation of a individual series using arrays.<\/p>\n\n\n\n<p>To calculate the standard deviation,&nbsp;<code>calculateSD()<\/code>&nbsp;function is created. The array containing 10 elements is passed to the function and this function calculates the standard deviation and returns it to the&nbsp;<code>main()<\/code>&nbsp;function.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Example: Program to Calculate Standard Deviation<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>public class StandardDeviation {\n\n    public static void main(String&#91;] args) {\n        double&#91;] numArray = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };\n        double SD = calculateSD(numArray);\n\n        System.out.format(\"Standard Deviation = %.6f\", SD);\n    }\n\n    public static double calculateSD(double numArray&#91;])\n    {\n        double sum = 0.0, standardDeviation = 0.0;\n        int length = numArray.length;\n\n        for(double num : numArray) {\n            sum += num;\n        }\n\n        double mean = sum\/length;\n\n        for(double num: numArray) {\n            standardDeviation += Math.pow(num - mean, 2);\n        }\n\n        return Math.sqrt(standardDeviation\/length);\n    }\n}<\/code><\/pre>\n\n\n\n<p><strong>Output<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><samp>Standard Deviation = 2.872281<\/samp><\/code><\/pre>\n\n\n\n<p>In the above program, we&#8217;ve used the help of\u00a0Java Math.pow()\u00a0and\u00a0Java Math.sqrt()\u00a0to calculate the power and square root respectively.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This program calculates the standard deviation of a individual series using arrays. To calculate the standard deviation,&nbsp;calculateSD()&nbsp;function is created. The array containing 10 elements is passed to the function and this function calculates the standard deviation and returns it to the&nbsp;main()&nbsp;function. Example: Program to Calculate Standard Deviation Output In the above program, we&#8217;ve used the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[403],"tags":[],"_links":{"self":[{"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/posts\/1349"}],"collection":[{"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/comments?post=1349"}],"version-history":[{"count":0,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/posts\/1349\/revisions"}],"wp:attachment":[{"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/media?parent=1349"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/categories?post=1349"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/tags?post=1349"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}