{"id":1213,"date":"2025-09-26T13:23:12","date_gmt":"2025-09-26T12:23:12","guid":{"rendered":"https:\/\/monkey.ploogie.co.uk\/?page_id=1213"},"modified":"2026-01-13T13:44:44","modified_gmt":"2026-01-13T13:44:44","slug":"mwnci-covariance-function","status":"publish","type":"page","link":"https:\/\/monkey.ploogie.co.uk\/index.php\/mwnci-covariance-function\/","title":{"rendered":"Mwnci covariance() Function"},"content":{"rendered":"<h2><span id=\"Syntax\" class=\"mw-headline\">Syntax<\/span><\/h2>\n<p>covariance(<i><b>array<\/b>, <b>array<\/b>, <b>string<\/b><\/i>)<\/p>\n<h2><span id=\"Description\" class=\"mw-headline\">Description<\/span><\/h2>\n<p>The\u00a0<em>covariance()<\/em> method calculates and returns the covariance of two data sets. The optional 3rd argument is a single character &#8220;<em>s<\/em>&#8220;, &#8220;<em>p<\/em>&#8221; to give the <em>sample<\/em>, or <em>population<\/em> covariance.<\/p>\n<p>If the covariance type is not given as the 3rd argument, then the result defaults to <em>sample<\/em><\/p>\n<p>In the term of statistics and mathematics, covariance definition elaborates as the measurement of the relationship between two random variables (X, Y). In simple words, covariance is said to be a measure of how much two random variables can vary together. <\/p>\n<p>Covariance can be positive or negative. Positive covariance means the two data sets are likely to move in the same way. While a negative covariance indicates that as one data set rises, the other tends to fall.<\/p>\n<h2><span id=\"Example\" class=\"mw-headline\">Example<\/span><\/h2>\n<pre>include(\"stats\")\r\na=[1, 2, 3]\r\nb=[10, 20, 27]\r\nprintln(covariance(a,b,\"s\"))\r\nprintln(covariance(a,b))\r\nprintln(covariance(a,b,\"p\"))\r\n\r\n8.5\r\n8.5\r\n5.666666666666667\r\n<\/span><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Syntax covariance(array, array, string) Description The\u00a0covariance() method calculates and returns the covariance of two data sets. The optional 3rd argument is a single character &#8220;s&#8220;, &#8220;p&#8221; to give the sample, or population covariance. If the covariance type is not given as the 3rd argument, then the result defaults to sample In the term of statistics &hellip; <a href=\"https:\/\/monkey.ploogie.co.uk\/index.php\/mwnci-covariance-function\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Mwnci covariance() Function&#8221;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-1213","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/monkey.ploogie.co.uk\/index.php\/wp-json\/wp\/v2\/pages\/1213","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/monkey.ploogie.co.uk\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/monkey.ploogie.co.uk\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/monkey.ploogie.co.uk\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/monkey.ploogie.co.uk\/index.php\/wp-json\/wp\/v2\/comments?post=1213"}],"version-history":[{"count":4,"href":"https:\/\/monkey.ploogie.co.uk\/index.php\/wp-json\/wp\/v2\/pages\/1213\/revisions"}],"predecessor-version":[{"id":1343,"href":"https:\/\/monkey.ploogie.co.uk\/index.php\/wp-json\/wp\/v2\/pages\/1213\/revisions\/1343"}],"wp:attachment":[{"href":"https:\/\/monkey.ploogie.co.uk\/index.php\/wp-json\/wp\/v2\/media?parent=1213"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}