{
  "category": "Statistical functions",
  "display_name": "COVARIANCE.P",
  "entry_kind": "built_in_function",
  "eval_api": {
    "method": "POST",
    "url": "https://handbook.dnacalc.com/api/eval"
  },
  "function_id": "FUNC.COVARIANCE.P",
  "implementation_state": {
    "answer_bank": null,
    "detail": "Recorded: 6 workbook cells.",
    "dnacalc_commit": "9e1884369a678158dd82d3d74188daf986995e87",
    "in_catalogue": true,
    "state": "matches",
    "state_label": "Matches every recorded Excel answer",
    "summary": "Matches all 6 recorded answers",
    "workbook_corpus": {
      "cells": 6,
      "matched": 6
    }
  },
  "implementations": [
    {
      "commit": "9e1884369a678158dd82d3d74188daf986995e87",
      "flavour": "excel-compatibility-candidate",
      "language": "Rust",
      "name": "CalcFunc",
      "own_code": [
        "https://github.com/DnaCalc/DnaCalc/blob/9e1884369a678158dd82d3d74188daf986995e87/crates/calc-func/src/catalogue/statistics.rs#L356-L358"
      ],
      "repository": "https://github.com/DnaCalc/DnaCalc",
      "shared_code": [
        "ported/paired_stats_common::means",
        "ported/paired_stats_common::covariance_from_pairs"
      ],
      "source": "https://github.com/DnaCalc/DnaCalc/blob/9e1884369a678158dd82d3d74188daf986995e87/crates/calc-func/src/catalogue/statistics.rs#L356-L358",
      "state": "matches",
      "suite": null,
      "summary": "Matches all 6 recorded answers"
    }
  ],
  "json_url": "https://handbook.dnacalc.com/api/functions/FUNC.COVARIANCE.P.json",
  "name": "COVARIANCE.P",
  "notes": [],
  "schema": "efh.function-reference/v1",
  "section_order": [
    "what-it-does",
    "try-it",
    "quirks",
    "how-to-implement",
    "version-differences",
    "alternatives"
  ],
  "sections": {
    "alternatives": "\n[CORREL](FUNC.CORREL.md) removes units and scales to a correlation coefficient. [COVARIANCE.S](FUNC.COVARIANCE.S.md) changes the denominator.\n\n\n",
    "how-to-implement": "\nThe current paired collector checks equal original cell counts, then walks both arguments together and retains only positions where both values are numeric. It checks the first argument’s value before the second’s at each position. This admission step belongs before either mean is calculated.\n\n1. Let `n` be the number of retained pairs. Apply the empty-set and sample-count checks above.\n2. Accumulate separate binary64 sums `Sx` and `Sy`, then store `mx=Sx/n` and `my=Sy/n`.\n3. Starting from `C=0`, visit each retained pair and add the ordinary binary64 product `(x-mx)*(y-my)`.\n4. Return `C/n`. The current helper uses ordinary binary64 operations here; no stored-stage identification for the whole Excel route is claimed.\n\nFor the excluded-position example, the retained means are two and four. Products `(-1)*(-2)` and `1*2` total four. Divide by two to obtain population covariance two. The count is two, not the three original positions.\n\nCovariance retains both input scales: multiplying every `y` by ten multiplies the mathematical covariance by ten. [CORREL](FUNC.CORREL.md) normalizes that scale away. The exact-arithmetic relation does not certify the last bits of either implementation.\n\n\n",
    "quirks": "\nThe original arguments need the same number of cells; otherwise the current collector returns `#N/A`. It flattens them in traversal order and preserves positional alignment. If either side of a position is text, logical or blank, that position supplies no pair. Numeric zero still participates. Worksheet errors are read and propagated rather than silently removed with a nonnumeric partner.\n\nAn empty set of eligible pairs gives `#DIV/0!`; one pair has zero population covariance. Do not filter each side independently and zip the remaining lists: that can pair observations that never belonged together.\n\n\n",
    "sources": "\n- [Microsoft: COVARIANCE.P function](https://support.microsoft.com/en-us/excel/functions/covariance-p-function), opened 6 November 2026; syntax, documented argument rules and errors.\n- [DnaCalc pair collector](https://github.com/DnaCalc/DnaCalc/blob/da3ecc4fb19a3a5529708c311d0e8f05688ac165/crates/calc-func/src/catalogue/kit.rs), `pairs` and `PairScalars::SkipNonnumeric`.\n- [DnaCalc implementation](https://github.com/DnaCalc/DnaCalc/blob/da3ecc4fb19a3a5529708c311d0e8f05688ac165/crates/calc-func/src/ported/paired_stats_common.rs); implementation steps and the limits identified in the text.\n\n",
    "try-it": "\n`=COVARIANCE.P({1,2,3},{2,4,6})` returns approximately `1.33333333333333`. The means are two and four; the paired deviation products are two, zero and two.\n\nWith an excluded position, `=COVARIANCE.P({1,\"missing\",3},{2,4,6})` returns `2` under the current paired collection rule. The second position is skipped on both sides; the remaining pairs are `(1,2)` and `(3,6)`.\n\n\n",
    "version-differences": "\nNo same-input comparison between named Excel builds is recorded for this function here. The documented behaviour below is not a measurement of every Excel release.\n\n\n",
    "what-it-does": "\n`COVARIANCE.P(array1, array2)` measures population covariance: whether paired observations tend to move in the same direction. It averages products of deviations using divisor `n`. Covariance carries the product of the two input units.\n\n\n"
  },
  "signature": {
    "display": "COVARIANCE.P(array1, array2)",
    "parameters": [
      {
        "description": null,
        "name": "array1",
        "optional": false,
        "repeats": false
      },
      {
        "description": null,
        "name": "array2",
        "optional": false,
        "repeats": false
      }
    ],
    "trailing_repeats": false
  },
  "sources": {
    "metadata": {
      "admission": {
        "label": "implemented",
        "reason": null
      },
      "arity": {
        "max": 2,
        "min": 2
      },
      "category": "Statistical functions",
      "classification": {
        "arg_preparation_profile": "ValuesOnlyPreAdapter",
        "coercion_lift_profile": "Custom",
        "determinism_class": "Deterministic",
        "error_collapse_profile": "None",
        "fec_dependency_profile": "None",
        "host_interaction_class": "None",
        "kernel_signature_class": "Custom",
        "rich_value_usage": "RichBlind",
        "surface_fec_dependency_profile": "RefOnly",
        "thread_safety_class": "SafePure",
        "volatility_class": "NonVolatile"
      },
      "descriptions": {
        "long": null,
        "short": "Covariance of two data sets taken as a whole population",
        "short_source": "dna-calc-own"
      },
      "docs": {
        "english_description": "Returns covariance, the average of the products of paired deviations",
        "microsoft_url": "https://support.microsoft.com/en-us/office/covariance-p-function-6f0e1e6d-956d-4e4b-9943-cfef0bf9edfc"
      },
      "entry_kind": "built_in_function",
      "localized_family_names": null,
      "localized_names": [
        {
          "locale": "ar-SA",
          "name": "COVARIANCE.P"
        },
        {
          "locale": "bg-BG",
          "name": "COVARIANCE.P"
        },
        {
          "locale": "cs-CZ",
          "name": "COVARIANCE.P"
        },
        {
          "locale": "da-DK",
          "name": "KOVARIANS.P"
        },
        {
          "locale": "de-DE",
          "name": "COVARIANCE.P"
        },
        {
          "locale": "el-GR",
          "name": "COVARIANCE.P"
        },
        {
          "locale": "en-AU",
          "name": "COVARIANCE.P"
        },
        {
          "locale": "en-GB",
          "name": "COVARIANCE.P"
        },
        {
          "locale": "en-US",
          "name": "COVARIANCE.P"
        },
        {
          "locale": "es-ES",
          "name": "COVARIANCE.P"
        },
        {
          "locale": "et-EE",
          "name": "COVARIANCE.P"
        },
        {
          "locale": "fi-FI",
          "name": "KOVARIANSSI.P"
        },
        {
          "locale": "fr-FR",
          "name": "COVARIANCE.PEARSON*"
        },
        {
          "locale": "he-IL",
          "name": "COVARIANCE.P"
        },
        {
          "locale": "hr-HR",
          "name": "COVARIANCE.P"
        },
        {
          "locale": "hu-HU",
          "name": "KOVÁRCIÁNS. P"
        },
        {
          "locale": "id-ID",
          "name": "COVARIANCE.P"
        },
        {
          "locale": "it-IT",
          "name": "COVARIANCE.P"
        },
        {
          "locale": "ja-JP",
          "name": "COVARIANCE.P"
        },
        {
          "locale": "ko-KR",
          "name": "COVARIANCE.P"
        },
        {
          "locale": "lt-LT",
          "name": "COVARIANCE.P"
        },
        {
          "locale": "lv-LV",
          "name": "COVARIANCE.P"
        },
        {
          "locale": "nb-NO",
          "name": "COVARIANCE.P"
        },
        {
          "locale": "nl-NL",
          "name": "COVARIANTIE.P"
        },
        {
          "locale": "pl-PL",
          "name": "KOWARIANCJA.POPUL"
        },
        {
          "locale": "pt-BR",
          "name": "COVARIÂNCIA.P"
        },
        {
          "locale": "pt-PT",
          "name": "COVARIÂNCIA.P"
        },
        {
          "locale": "ro-RO",
          "name": "COVARIANCE.P"
        },
        {
          "locale": "ru-RU",
          "name": "КОВАРИАЦИЯ.Г"
        },
        {
          "locale": "sk-SK",
          "name": "COVARIANCE.P"
        },
        {
          "locale": "sl-SI",
          "name": "COVARIANCE.P"
        },
        {
          "locale": "sr-Latn-RS",
          "name": "COVARIANCE.P"
        },
        {
          "locale": "sv-SE",
          "name": "KOVARIANS.P"
        },
        {
          "locale": "th-TH",
          "name": "COVARIANCE.P"
        },
        {
          "locale": "tr-TR",
          "name": "KOVARYANS.P"
        },
        {
          "locale": "uk-UA",
          "name": "COVARIANCE.P"
        },
        {
          "locale": "vi-VN",
          "name": "COVARIANCE.P"
        },
        {
          "locale": "zh-CN",
          "name": "COVARIANCE.P"
        },
        {
          "locale": "zh-HK",
          "name": "COVARIANCE.P"
        },
        {
          "locale": "zh-TW",
          "name": "COVARIANCE.P"
        }
      ],
      "signature": {
        "display": "COVARIANCE.P(array1, array2)",
        "parameters": [
          {
            "description": null,
            "name": "array1",
            "optional": false,
            "repeats": false
          },
          {
            "description": null,
            "name": "array2",
            "optional": false,
            "repeats": false
          }
        ],
        "trailing_repeats": false
      },
      "surface_name": "COVARIANCE.P",
      "version_marker": null,
      "xlcall": {
        "code": "492",
        "symbol": "xlfCovariance_p"
      }
    },
    "microsoft": "https://support.microsoft.com/en-us/office/covariance-p-function-6f0e1e6d-956d-4e4b-9943-cfef0bf9edfc"
  },
  "try_it": {
    "formula": "=COVARIANCE.P({1,2,3},{2,4,6})"
  },
  "url": "https://handbook.dnacalc.com/functions/COVARIANCE.P.html",
  "variants": [],
  "versions": []
}