LSDn calculates the standard deviation of the last n datapoints of a specified variable.
SYNTAX:
LSDn(Cx, optional Time Increment)
where :
Cx is a conditional variable x
n is the number of values to total
Time Increment Optional - specifies the source variables (Cx) Frequency when the Source Variable (CX) and target variable's (i.e. the variable being calculated) frequencies do not match.
NOTES:
The data points do not need to be on consecutive days/data slots.
Calculates every day that it can find n values, searching up to one year (366 days) backward
Does not calculate if n values are not available
Calculates the "Sample Standard Deviation" (not the population Standard Deviation), i.e. uses the formula:
![](http://www.opssys.com/InstantKB/Attachments/8c3135e1-668e-4081-af9d-15ac.png)
Where n is the number of samples, and x bar is the mean.
SEE ALSO: MSDn
EXAMPLE 1: Get the Standard Deviation of the last 7 values.
Source variable (70) is set to Daily and Target variable (100) is also set to Daily. Because both the Source and Target variables are the same (Daily), the time increment BYDAY will be used.
V13= LSD7(C11)
Variable 13 will be the standard deviation of the last 7values of variable 11:
![](http://www.opssys.com/InstantKB/Attachments/3cddd915-1e9c-4fc5-9b6c-fabd.png)
Example 2: Get standard deviation of last 5 values from an Hourly variable into a Daily Calculation.
V1022 = LSD5(C1021,BYHOUR)
Note: You MUST specify the Time Increment (BYHOUR) that matches the source variables frequency (IE the source variable V1021 is Hourly, therefore we specify BYHOUR) in order for the function to return the correct value.
When calculating daily detail variables, the program will start on the first slot of the day being calculated and evaluate the first 5 non blank values going backward in time for up to a year. See screenshot below
![](http://www.opssys.com/InstantKB/Attachments/7952885d-82d3-4ea7-a04c-11c1.png)
See: Working with Daily Detail Variables in Calculations.