TimeSeries Functions
Functions that take a TimeSeries as their input
abs
Transforms all values of the input variable to absolute (positive) values.
Works with:
Syntax
abs(var)
Examples
Timeseries
at = TimeSeries("DAILY")
at.add("2020-11-01", 12.5)
at.add("2020-11-02", -12.75)
at.add("2020-11-03", 12.9)
at.add("2020-11-04", -11.5)
at.add("2020-11-05", 11.9)
absat = abs(at)
print absat.values
[
{"2020-11-01": 12.5},
{"2020-11-02": 12.75},
{"2020-11-03": 12.9},
{"2020-11-04": 11.5},
{"2020-11-05": 11.9}
]
List
testarray = [-1,6,0,-2]
print abs(testarray)
Curve
expiry = ExpiryCalendar(BusinessCalendar())
expiry.addRule("go back 1 day using calendar")
ondate = CurveDate(Date("2020-12-01"), expiry)
c1 = Curve(ondate)
c1.add(Contract(ondate, "2021M01", 12.5))
c1.add(Contract(ondate, "2021M02", -12.75))
c1.add(Contract(ondate, "2021M03", 13.0))
print abs(c1)
Scalar
print abs(-2)
2
acos
Returns the arc cosine of a value; the returned angle is in the range 0.0 through pi.
Special case: If the argument is NaN or its absolute value is greater than 1, then the result is NaN.
The computed result must be within 1 ulp of the exact result. Results must be semi-monotonic.
Works with:
Syntax
acos(var)
asin
Returns the arc sine of a value; the returned angle is in the range -pi/2 through pi/2.
Special cases:
- If the argument is NaN or its absolute value is greater than 1, then the result is NaN.
- If the argument is zero, then the result is a zero with the same sign as the argument.
Works with:
Syntax
asin(var)
atan
Returns the arc tangent of a value; the returned angle is in the range -pi/2 through pi/2.
Special cases:
- If the argument is NaN or its absolute value is greater than 1, then the result is NaN.
- If the argument is zero, then the result is a zero with the same sign as the argument.
The computed result must be within 1 ulp of the exact result. Results must be semi-monotonic.
Works with:
- Scalars
- Timeseries
- Curves
- Lists/Arrays
Syntax
atan(var)
atan2
Returns the angle theta from the conversion of rectangular coordinates (x, y) to polar coordinates (r, theta). This method computes the phase theta by computing an arc tangent of y/x in the range of -pi to pi.
Special cases:
- If either argument is NaN, then the result is NaN.
- If the first argument is positive zero and the second argument is positive, or the first argument is positive and finite and the second argument is positive infinity, then the result is positive zero.
- If the first argument is negative zero and the second argument is positive, or the first argument is negative and finite and the second argument is positive infinity, then the result is negative zero.
- If the first argument is positive zero and the second argument is negative, or the first argument is positive and finite and the second argument is negative infinity, then the result is the double value closest to pi.
- If the first argument is negative zero and the second argument is negative, or the first argument is negative and finite and the second argument is negative infinity, then the result is the double value closest to -pi.
- If the first argument is positive and the second argument is positive zero or negative zero, or the first argument is positive infinity and the second argument is finite, then the result is the double value closest to pi/2.
- If the first argument is negative and the second argument is positive zero or negative zero, or the first argument is negative infinity and the second argument is finite, then the result is the double value closest to -pi/2.
- If both arguments are positive infinity, then the result is the double value closest to pi/4.
- If the first argument is positive infinity and the second argument is negative infinity, then the result is the double value closest to 3*pi/4.
- If the first argument is negative infinity and the second argument is positive infinity, then the result is the double value closest to -pi/4.
- If both arguments are negative infinity, then the result is the double value closest to -3*pi/4.
The computed result must be within 2 ulps of the exact result. Results must be semi-monotonic.
Works with:
- Scalars
- Timeseries
- Curves
- Lists/Arrays
Syntax
atan2(ordinate, abscissa)
cbrt
Returns the cube root of a double value. For positive finite x, cbrt(-x) == -cbrt(x); that is, the cube root of a negative value is the negative of the cube root of that value's magnitude.
Special cases:
- If the argument is NaN, then the result is NaN.
- If the argument is infinite, then the result is an infinity with the same sign as the argument.
- If the argument is zero, then the result is a zero with the same sign as the argument.
The computed result must be within 1 ulp of the exact result.
Works with:
- Scalars
- Timeseries
- Curves
- Lists/Arrays
Syntax
cbrt(var)
correlation
PearsonsCorrelation computes correlations defined by the formula:
cor(X, Y) = sum[(xi - E(X))(yi - E(Y))] / [(n - 1)s(X)s(Y)]
where E(X)
and E(Y)
are means of X
and Y
and s(X)
, s(Y)
are standard deviations.
Syntax
correlation(list)
The list parameter is a list of variables which can be one of:
- Timeseries
- Reference to a Timeseries
- String id of a Timeseries
Example
Con = TimeSeries("2021-10-01", "BUSINESS", [8.12,1.19,2.82,4.1,-6.31,6.87,1.16,-0.63,1.25,0.93])
Man = TimeSeries("2021-10-01", "BUSINESS", [8.98,4.23,0.71,2.47,-8.29,7.34,-0.39,-2.18,3.86,-0.84])
Tech = TimeSeries("2021-10-01", "BUSINESS", [8.97,5.32,3.31,6,-7.75,7.51,3.38,-2.33,1.01,3.06])
Health = TimeSeries("2021-10-01", "BUSINESS", [5.25,3.23,0.48,-3.13,-3.37,6.84,-2.19,-0.61,-0.94,4.73])
lts = [Con, Man, Tech, Health]
print correlation(lts)
Output
Con Man Tech Health
Con 1 0.926711 0.940898 0.627738
Man 0.926711 1 0.903867 0.660247
Tech 0.940898 0.903867 1 0.624856
Health 0.627738 0.660247 0.624856 1
cos
Returns the trigonometric cosine of an angle.
Special cases:
- If the argument is NaN or an infinity, then the result is NaN.
The computed result must be within 1 ulp of the exact result. Results must be semi-monotonic.
Works with:
- Scalars
- Timeseries
- Curves
- Lists/Arrays
Syntax
cos(var)
cosh
Returns the hyperbolic cosine of a double value. The hyperbolic cosine of x is defined to be (ex + e-x)/2 where e is Euler's number.
Special cases:
- If the argument is NaN, then the result is NaN.
- If the argument is infinite, then the result is positive infinity.
- If the argument is zero, then the result is 1.0.
The computed result must be within 1 ulp of the exact result. Results must be semi-monotonic.
Works with:
- Scalars
- Timeseries
- Curves
- Lists/Arrays
Syntax
cosh(var)
covariance
Unbiased covariances are given by the formula
cov(X, Y) = sum [(xi - E(X))(yi - E(Y))] / (n - 1)
where E(X)
is the mean of X
and E(Y)
is the mean of the Y
values.
Non-bias-corrected estimates use n
in place of n - 1
.
Whether or not covariances are bias-corrected is determined by the optional parameter, biasCorrected which defaults to true.
Syntax
covariance(list)
covariance(list, biasCorrected)
The list parameter is a list of variables which can be one of:
- Timeseries
- Reference to a Timeseries
- String id of a Timeseries
The biasCorrected parameter is a boolean.
Example
Con = TimeSeries("2021-10-01", "BUSINESS", [8.12,1.19,2.82,4.1,-6.31,6.87,1.16,-0.63,1.25,0.93])
Man = TimeSeries("2021-10-01", "BUSINESS", [8.98,4.23,0.71,2.47,-8.29,7.34,-0.39,-2.18,3.86,-0.84])
Tech = TimeSeries("2021-10-01", "BUSINESS", [8.97,5.32,3.31,6,-7.75,7.51,3.38,-2.33,1.01,3.06])
Health = TimeSeries("2021-10-01", "BUSINESS", [5.25,3.23,0.48,-3.13,-3.37,6.84,-2.19,-0.61,-0.94,4.73])
lts = [Con, Man, Tech, Health]
mc = covariance(lts)
print mc
mc = covariance(lts, false)
print mc
Output
Con Man Tech Health
Con 16.141200 18.532833 18.617622 9.361344
Man 18.532833 24.777610 22.158876 12.199110
Tech 18.617622 22.158876 24.256440 11.423153
Health 9.361344 12.199110 11.423153 13.777943
Con Man Tech Health
Con 14.527080 16.679550 16.755860 8.425210
Man 16.679550 22.299849 19.942988 10.979199
Tech 16.755860 19.942988 21.830796 10.280838
Health 8.425210 10.979199 10.280838 12.400149
cave
Returns the cumulative average of the values of a List or Timeseries
Syntax
cave(list)
cave(timeseries)
cave(timeseries, calendar)
If you supply a Timeseries and a Calendar - the output will be cumulative average of the values aligned to the output calendar
Example
input = TimeSeries("DAILY")
input.add("2020-10-30", 10)
input.add("2020-10-31", 10)
input.add("2020-11-01", 11)
input.add("2020-11-02", 12)
input.add("2020-11-03", 12.9)
input.add("2020-11-04", 11.5)
input.add("2020-11-05", 11.9)
v = cave(input)
print v.values
v = cave(input, MonthlyCalendar())
print v.values
testarray = [-1,6,0,-2]
print cave(testarray)
[
2020-10-30 10.0
2020-10-31 10.0
2020-11-01 10.333333
2020-11-02 10.750000
2020-11-03 11.180000
2020-11-04 11.233333
2020-11-05 11.328571
]
[
2020-10-01 10
2020-11-01 11.328571
]
[
-1.0
2.500000
1.666667
0.750000
]
cmax
Returns the cumulative maximum of the values of a List or Timeseries
Syntax
cmax(list)
cmax(timeseries)
cmax(timeseries, calendar)
If you supply a Timeseries and a Calendar - the output will be cumulative maximum of the values aligned to the output calendar
Example
input = TimeSeries("DAILY")
input.add("2020-10-30", 10)
input.add("2020-10-31", 10)
input.add("2020-11-01", 11)
input.add("2020-11-02", 12)
input.add("2020-11-03", 12.9)
input.add("2020-11-04", 11.5)
input.add("2020-11-05", 11.9)
v = cmax(input)
print v.values
v = cmax(input, MonthlyCalendar())
print v.values
testarray = [-1,6,0,-2]
print cmax(testarray)
[
2020-10-30 10.0
2020-10-31 10.0
2020-11-01 11.0
2020-11-02 12.0
2020-11-03 12.900000
2020-11-04 12.900000
2020-11-05 12.900000
]
[
2020-10-01 10
2020-11-01 12.900000
]
[
-1.0
6.0
6.0
6.0
]
cmin
Returns the cumulative minimum of the values of a List or Timeseries
Syntax
cmin(list)
cmin(timeseries)
cmin(timeseries, calendar)
If you supply a Timeseries and a Calendar - the output will be cumulative minimum of the values aligned to the output calendar
Example
input = TimeSeries("DAILY")
input.add("2020-10-30", 10)
input.add("2020-10-31", 10)
input.add("2020-11-01", 11)
input.add("2020-11-02", 9.9)
input.add("2020-11-03", 12.9)
input.add("2020-11-04", 11.5)
input.add("2020-11-05", 11.9)
v = cmin(input)
print v.values
v = cmin(input, MonthlyCalendar())
print v.values
testarray = [-1,6,0,-2]
print cmin(testarray)
[
2020-10-30 10.0
2020-10-31 10.0
2020-11-01 10.0
2020-11-02 9.900000
2020-11-03 9.900000
2020-11-04 9.900000
2020-11-05 9.900000
]
[
2020-10-01 10
2020-11-01 9.900000
]
[
-1.0
-1.0
-1.0
-2.0
]
csum
Returns the cumulative sum of the values of a List or Timeseries
Syntax
csum(list)
csum(timeseries)
csum(timeseries, calendar)
If you supply a Timeseries and a Calendar - the output will be cumulative sums of the values aligned to the output calendar
Example
input = TimeSeries("DAILY")
input.add("2020-10-30", 10)
input.add("2020-10-31", 10)
input.add("2020-11-01", 11)
input.add("2020-11-02", 12)
input.add("2020-11-03", 12.9)
input.add("2020-11-04", 11.5)
input.add("2020-11-05", 11.9)
sum = csum(input)
print sum.values
sum = csum(input, MonthlyCalendar())
print sum.values
testarray = [-1,6,0,-2]
print csum(testarray)
[
2020-10-30 10.0
2020-10-31 20.0
2020-11-01 31.0
2020-11-02 43.0
2020-11-03 55.900000
2020-11-04 67.400000
2020-11-05 79.300000
]
[
2020-10-01 20
2020-11-01 79.300000
]
[
-1.0
5.0
5.0
3.0
]
diff
Returns a TimeSeries with the absolute change values from one observation to the next.
Syntax
diff(var)
Example
input = TimeSeries("DAILY")
input.add("2020-11-01", 12.5)
input.add("2020-11-02", 12.75)
input.add("2020-11-03", 12.9)
input.add("2020-11-04", 11.5)
input.add("2020-11-05", 11.9)
d = diff(input)
print d.values
[
2020-11-02 0.250000
2020-11-03 0.150000
2020-11-04 -1.400000
2020-11-05 0.400000
]
exp
Returns Euler's number e raised to the power of a double value.
Special cases:
- If the argument is NaN, the result is NaN.
- If the argument is positive infinity, then the result is positive infinity.
- If the argument is negative infinity, then the result is positive zero.
The computed result must be within 1 ulp of the exact result. Results must be semi-monotonic.
Works with:
- Scalars
- Timeseries
- Curves
- Lists/Arrays
Syntax
exp(var)
geomean
Returns the geometric average value from a list of values.
Geometric mean, sometimes referred to as compounded annual growth rate or time-weighted rate of return, is the average rate of return of a set of values calculated using the products of the terms.
Geometric mean is an important tool for calculating portfolio performance for many reasons, but one of the most significant is it takes into account the effects of compounding.
Syntax
var = geomean(List or TimeSeries)
Result
A number representing the geometric average value from the input List or TimeSeries
Example
data = [1,2,3]
print geomean(data)
1.817121
log
Returns the natural logarithm (base e) of a double value.
Special cases:
- If the argument is NaN or less than zero, then the result is NaN.
- If the argument is positive infinity, then the result is positive infinity.
- If the argument is positive zero or negative zero, then the result is negative infinity.
The computed result must be within 1 ulp of the exact result. Results must be semi-monotonic.
Works with:
- Scalars
- Timeseries
- Curves
- Lists/Arrays
Syntax
log(var)
log10
Returns the base 10 logarithm of a double value.
Special cases:
- If the argument is NaN or less than zero, then the result is NaN.
- If the argument is positive infinity, then the result is positive infinity.
- If the argument is positive zero or negative zero, then the result is negative infinity.
- If the argument is equal to 10n for integer n, then the result is n.
The computed result must be within 1 ulp of the exact result. Results must be semi-monotonic.
Works with:
- Scalars
- Timeseries
- Curves
- Lists/Arrays
Syntax
log10(var)
log1p
Returns the natural logarithm of the sum of the argument and 1. Note that for small values x, the result of log1p(x) is much closer to the true result of ln(1 + x) than the floating-point evaluation of log(1.0+x).
Special cases:
- If the argument is NaN or less than -1, then the result is NaN.
- If the argument is positive infinity, then the result is positive infinity.
- If the argument is negative one, then the result is negative infinity.
- If the argument is zero, then the result is a zero with the same sign as the argument.
The computed result must be within 1 ulp of the exact result. Results must be semi-monotonic.
Works with:
- Scalars
- Timeseries
- Curves
- Lists/Arrays
Syntax
log10(var)
max
Returns the largest value from a list of values.
Syntax
var = max(List or TimeSeries)
Result
A number representing the largest value from the input List or TimeSeries
Example
data = [5,6.7,-2]
print max(data)
6.7
mean
Returns the arithmetic average value from a list of values
Returns the arithmetic average value from a list of values using the formula:
Syntax
var = mean(List or TimeSeries)
Result
A number representing the arithmetic average value from the input List or TimeSeries
Example
data = [1,2,3]
print mean(data)
2
min
Returns the smallest value from a list of values.
Syntax
var = min(List or TimeSeries)
Result
A number representing the smallest value from the input List or TimeSeries
Example
data = [5,6.7,-2]
print min(data)
-2
pct
Returns a TimeSeries with the percentage change values from one observation to the next.
Syntax
pct(var)
Example
input = TimeSeries("DAILY")
input.add("2020-11-01", 10)
input.add("2020-11-02", 12)
input.add("2020-11-03", 12.9)
input.add("2020-11-04", 11.5)
input.add("2020-11-05", 11.9)
d = pct(input)
print d.values
[
2020-11-02 0.200000
2020-11-03 0.075000
2020-11-04 -0.108527
2020-11-05 0.034783
]
pow
Returns the value of the first argument raised to the power of the second argument.
The computed result must be within 1 ulp of the exact result. Results must be semi-monotonic.
Works with:
- Scalars
- Timeseries
- Curves
- Lists/Arrays
Syntax
pow(base, exponent)
scale
Rescales a TimeSeries to a different calendar
Syntax
ts = scale(input, calendar)
ts = scale(input, calendar, observed)
ts = scale(input, calendar, observed, distribution)
Observed
Observed relates to the way the value is recorded and can be one of the following:
- beginning
- end
- averaged
- summed
- high
- low
- delta
- none
Distribution
Distribution relates to the way a value is distributed across observations when you are scaling from lower to a higher frequency calendar and can be one of the following:
- constant
- linear
- cubic
For more information and examples of scaling TimeSeries, see here
Example
// Daily to Weekly
tsd = TimeSeries("2021-10-01", "DAILY", [12.5,13,14,15.5,14.2])
tsw = scale(tsd, WeeklyCalendar("Friday"))
print tsw.values
[
2021-09-24 12.500000
2021-10-01 14.200000
]
shift
Returns a TimeSeries that is shifted in time by the number of specified observations.
The function takes a Timeseries as the first parameter and an integer (positive or negative).
Syntax
shift(series, number)
Example
input = TimeSeries("DAILY")
input.add("2020-11-01", 10)
input.add("2020-11-02", 12)
input.add("2020-11-03", 12.9)
input.add("2020-11-04", 11.5)
input.add("2020-11-05", 11.9)
prior = shift(input, -1)
print prior.values
[
2020-10-31 10
2020-11-01 12
2020-11-02 12.900000
2020-11-03 11.500000
2020-11-04 11.900000
]
simpleRegression
SimpleRegression provides ordinary least squares regression with one independent variable estimating the linear model: y = intercept + slope * x
or y = slope * x
Standard errors for intercept
and slope
are available as well as ANOVA, r-square and Pearson's r statistics.
Observations (x,y pairs) are added as time=x and value=y
The function result can also be used to predict other values given a Date input as shown in the example
Syntax
var = simpleRegression(TimeSeries)
Result
The output from this function is an Object with properties representing some statistical calculations on the input time-series as shown in the table below:
Property | Description |
---|---|
intercept | The intercept (often labeled the constant) is the expected mean value of Y when all X=0. Start with a regression equation with one predictor, X. If X sometimes equals 0, the intercept is simply the expected mean value of Y at that value. If X never equals 0, then the intercept has no intrinsic meaning. |
slope | Slope is calculated by finding the ratio of the "vertical change" to the "horizontal change" between (any) two distinct points on a line. Sometimes the ratio is expressed as a quotient ("rise over run"), giving the same number for every two distinct points on the same line. |
slopeStdErr | The standard error of the regression slope, s (also called the standard error of estimate) represents the average distance that your observed values deviate from the regression line. The smaller the “s” value, the closer your values are to the regression line. |
interceptStdErr | The standard error of the the intercept allows you to test whether or not the estimated intercept is statistically significant from a specified(hypothesized) value ... normally 0.0 . If you test against 0.0 and fail to reject then you can then re-estimate your model without the intercept term being present. |
meanSquareErr | The mean squared error (MSE) or mean squared deviation (MSD) of an estimator (of a procedure for estimating an unobserved quantity) measures the average of the squares of the errors—that is, the average squared difference between the estimated values and the actual value |
N | N is the number of elements in a population |
R | The Pearson correlation coefficient, also referred to as Pearson's r, the Pearson product-moment correlation coefficient, or the bivariate correlation, is a statistic that measures linear correlation between two variables X and Y. It has a value between +1 and −1. |
regressionSumSquares | Regression sum of squares (also known as the sum of squares due to regression or explained sum of squares) The regression sum of squares describes how well a regression model represents the modeled data. A higher regression sum of squares indicates that the model does not fit the data well. |
RSquare | R-squared (R2) is a statistical measure that represents the proportion of the variance for a dependent variable that's explained by an independent variable or variables in a regression model. ... So, if the R2 of a model is 0.50, then approximately half of the observed variation can be explained by the model's inputs |
significance | Statistical significance is a determination that a relationship between two or more variables is caused by something other than chance. Statistical hypothesis testing is used to determine whether the result of a data set is statistically significant. |
slopeConfidenceInterval | With simple linear regression, to compute a confidence interval for the slope, the critical value is a t score with degrees of freedom equal to n - 2. ... df = n - 2 = 101 - 2 = 99. The critical value is the t statistic having 99 degrees of freedom and a cumulative probability equal to 0.995. |
sumOfCrossProducts | The sum of cross products between all the elements of columns j and k is represented by Σ XrjXrk, summed over r. A matrix of sums of squares and sums of cross products is represented by X' X, as shown below. Thus, the diagonal elements of X' X are sums of squares, and the off-diagonal elements are cross products. |
sumSquaredErrors | In statistics, the residual sum of squares (RSS), also known as the sum of squared residuals (SSR) or the sum of squared estimate of errors (SSE), is the sum of the squares of residuals (deviations predicted from actual empirical values of data). |
totalSumSquares | The Total SS (TSS or SST) tells you how much variation there is in the dependent variable. Total SS = Σ(Yi – mean of Y)2. Note: Sigma (Σ) is a mathematical term for summation or “adding up.” It's telling you to add up all the possible results from the rest of the equation |
XSumSquares | The sum of squares is a measure of deviation from the mean. In statistics, the mean is the average of a set of numbers and is the most commonly used measure of central tendency. The arithmetic mean is simply calculated by summing up the values in the data set and dividing by the number of values |
The result also has methods as detailed in the following table:
Method | Description |
---|---|
predict(date) | Use the regression model to predict the y value for a new x (Date) value |
Example
input = TimeSeries("DAILY")
input.add("2020-11-01", 12.5)
input.add("2020-11-02", 12.8)
input.add("2020-11-03", 12.9)
input.add("2020-11-04", 11.5)
input.add("2020-11-05", 11.9)
reg = simpleRegression(input)
print reg.slope
print reg.slopeStdErr
print reg.slopeConfidenceInterval
print reg.intercept
print reg.interceptStdErr
print reg.meanSquareErr
print reg.N
print reg.R
print reg.regressionSumSquares
print reg.RSquare
print reg.significance
print reg.sumOfCrossProducts
print reg.sumSquaredErrors
print reg.totalSumSquares
print reg.XSumSquares
// Predict the next value
print reg.predict(Date("2020-11-06"))
sin
Returns the trigonometric sine of an angle.
Special cases:
- If the argument is NaN or an infinity, then the result is NaN.
- If the argument is zero, then the result is a zero with the same sign as the argument.
The computed result must be within 1 ulp of the exact result. Results must be semi-monotonic.
Works with:
- Scalars
- Timeseries
- Curves
- Lists/Arrays
Syntax
sin(var)
sinh
Returns the hyperbolic sine of a double value. The hyperbolic sine of x is defined to be (ex - e-x)/2 where e is Euler's number.
Special cases:
- If the argument is NaN, then the result is NaN.
- If the argument is infinite, then the result is an infinity with the same sign as the argument.
- If the argument is zero, then the result is a zero with the same sign as the argument.
The computed result must be within 1 ulp of the exact result. Results must be semi-monotonic.
Works with:
- Scalars
- Timeseries
- Curves
- Lists/Arrays
Syntax
sinh(var)
sqrt
Returns the correctly rounded positive square root of a double value.
Special cases:
- If the argument is NaN or less than zero, then the result is NaN.
- If the argument is positive infinity, then the result is positive infinity.
- If the argument is positive zero or negative zero, then the result is the same as the argument.
- Otherwise, the result is the double value closest to the true mathematical square root of the argument value.
Works with:
- Scalars
- Timeseries
- Curves
- Lists/Arrays
Syntax
sqrt(var)
tan
Returns the trigonometric tangent of an angle.
Special cases:
- If the argument is NaN or an infinity, then the result is NaN.
- If the argument is zero, then the result is a zero with the same sign as the argument.
The computed result must be within 1 ulp of the exact result. Results must be semi-monotonic.
Works with:
- Scalars
- Timeseries
- Curves
- Lists/Arrays
Syntax
tan(var)
tanh
Returns the hyperbolic tangent of a double value. The hyperbolic tangent of x is defined to be (ex - e-x)/(ex + e-x), in other words, sinh(x)/cosh(x). Note that the absolute value of the exact tanh is always less than 1.
Special cases:
- If the argument is NaN, then the result is NaN.
- If the argument is zero, then the result is a zero with the same sign as the argument.
- If the argument is positive infinity, then the result is +1.0.
- If the argument is negative infinity, then the result is -1.0.
The computed result must be within 2.5 ulps of the exact result. The result of tanh for any finite input must have an absolute value less than or equal to 1. Note that once the exact result of tanh is within 1/2 of an ulp of the limit value of ±1, correctly signed ±1.0 should be returned.
Works with:
- Scalars
- Timeseries
- Curves
- Lists/Arrays
Syntax
tanh(var)
toDegrees
Converts an angle measured in radians to an approximately equivalent angle measured in degrees. The conversion from radians to degrees is generally inexact; users should not expect cos(toRadians(90.0)) to exactly equal 0.0.
Works with:
- Scalars
- Timeseries
- Curves
- Lists/Arrays
Syntax
toDegrees(var)
toRadians
Converts an angle measured in degrees to an approximately equivalent angle measured in radians. The conversion from degrees to radians is generally inexact.
Works with:
- Scalars
- Timeseries
- Curves
- Lists/Arrays
Syntax
toRadians(var)