standardDeviation

OPL function to return the standard deviation of an array

Purpose

OPL function to return the standard deviation of an array.

context type
Model files (.mod) - Not allowed in a CPLEX constraint block.
float

Syntax

standardDeviation(int[ ])
standardDeviation(dvar int[ ])

Description

This function returns the standard deviation of the array. It uses the n formula, not the (n-1) one; with the following Sn equation.

Sn equation

See http://mathworld.wolfram.com/StandardDeviation.html.

This function also works for integer arrays outside constraint blocks both in CP and CPLEX models. You can use this function within IBM ILOG Script statements by specifying the OPL namespace:


( Opl.xxx() )

Example

using CP;

int n = 5;

range R = 1..n;
dvar int x[R] in R;

subject to {
  ct: standardDeviation(x)<=10;
}