Cov
- Last UpdatedJan 11, 2023
- 2 minute read
- PI System
- PI Server 2024 R2
- PI Server
Determine the covariance between two sets of values given by attributes over a specified time range.
Syntax
Cov(x, y, mode, starttime, endtime, type [, pctgood])
Arguments
-
x
an attribute with the first set of time series data (such as PI point data reference) enclosed in single quotes
-
y
an attribute with the second set of time series data (such as PI point data reference) enclosed in single quotes
-
mode
a number that specifies how to align time-stamped values
choose from 0, 1 or 2 where:
0 represents the combination of time-stamped values from x and y
1 represents values from both attributes according to x's time stamps
2 represents values from both attributes according to y's time stamps
-
starttime
a time expression representing the beginning of a time range enclosed in single quotes; can be a relative time (such as '-3h') in reference to an absolute endtime
-
endtime
a time expression representing the end of a time range enclosed in single quotes; can be a relative time (such as '+1h') in reference to an absolute starttime
-
type
a number specifying the covariance type: use 0 for "population" and 1 for "sample"
-
pctgood
Optional. Minimum percentage of time during the time range that attribute values must be good.
You can set pctgood as a threshold to ensure that there are sufficient good values to calculate Cov.
Returns
Covariance of x and y
Exceptions
If the attribute has no good values or the pctgood minimum is not reached for the given time range, returns an error value
Notes
Bad values are excluded from Cov calculation
Note: If the attribute has very few good values during the time range, this function's result may not be trustworthy. Use the PctGood function to find out what percentage of the values is good
Example
-
Cov('att1', 'att2', 0, 't', '+1h', 1, 80)
[Return the sample covariance of 'att1' and 'att2' between 12:00 and 1:00am today when at least 80% of the values were good. Return an error when minimum pctgood is not reached]
-
Cov('att1', 'att2', 1, 't', '+1h', 1)
[Return the population covariance of 'att1' and 'att2' based on time stamps of 'att1' between 12:00 and 1:00am today]