IRI Blog Articles

Diving Deeper into Data Management



Standard Deviation, A Predictive Analytic Tool in CoSort

by Jackie Sabbagh

About Standard Deviation

Standard Deviation is a statistical measure of variance between data values and their mean (or average value). Standard deviation is calculated as the square root of that variance.

For that reason, the more spread apart the data, the higher the deviation. And the more observations that are input, the more accurate and valuable standard deviation output results are.

It’s common to see this measure used in the financial industry to gauge investment risk. For example, according to Investopedia,

“a volatile stock will have a high standard deviation while the deviation of a stable blue chip stock will be lower. A large dispersion tells us how much the return on the fund is deviating from the expected normal returns.”

Standard Deviation in CoSort

The rapid calculation of standard deviation is now a built-in aggregation function in the CoSort SortCL program. It can be used with these other SortCL aggregate transforms to output multi-level static, running, and sliding:

  • totals
  • averages
  • maximums
  • minimums
  • counts
  • multiplication results
  • ranked values
  • sequence numbers

Aggregating huge collections of data in the file system with CoSort is much faster, and more efficient than transforms in SQL, BI tools, or statistical applications — none of which are designed for big data integration, and otherwise require hardware upgrades or complex technologies like Hadoop to perform as well.

In addition, CoSort’s ability to maintain running aggregates of any length, and produce moving averages over any range, allow you to test predictive models and validate hypotheses about future market behavior based on historical data. By using standard deviation to measure volatility in this environment, you can make safer assumptions (based on normal distribution) to set expectations, and monitor and manage investment behavior accordingly.

CoSort and its SortCL program combine aggregations with other transformation, migration, protection, reformatting, and reporting functions. SortCL jobs use a simple, self-documenting 4GL for data definition and manipulation. The text scripts can also be created, modified, and deployed in a familiar Eclipse GUI with a syntax-aware editor, and seamless integration with BIRT for free, advanced data visualizations.

CoSort SortCL Job Sample [Tech Tip]

The example below is clipped for display purposes; one need only imagine intra- and inter-day trading data on multiple issues over many decades to conceive of possible input volumes. But here, given the first ten months of daily closing 2013 prices for the Dow Jones index in a file like this:

... [continuation]

… and this SortCL job script producing 20-day moving averages and their standard deviations,

  /FIELD=(date, POSITION = 1, SEPARATOR = ',')
  /FIELD=(closing, POSITION = 2, SEPARATOR = ',')
  /INCLUDE WHERE date > "07/01/2013"
/REPORT    # sorting not required
/OUTFILE=stdout     # piped records for console and BIRT display
  /FIELD=(date,  POSITION = 1, SEPARATOR = ',')
  /FIELD=(closing, POSITION = 2, SEPARATOR = ',')
  /FIELD=(twenty_mv_avg, POSITION = 3, SEPARATOR = ',')
  /FIELD=(s_t_d, POSITION = 4, SEPARATOR = ',')
  /FIELD=(upper = closing + std_dev, POSITION = 5, SEPARATOR = ',')  # upper
  /FIELD=(lower = closing - std_dev, POSITION = 6, SEPARATOR = ',')  # lower
  /AVERAGE twenty_mv_avg from closing running 20 
  /STANDARD std_dev from twenty_mv_avg running 20

… the output contains these values:

... [continuation]

where the standard deviation is shown between the twenty-day moving average and prices at the upper and lower ranges of the deviation for illustrative purposes.

When I ran this SortCL job from BIRT in the IRI Workbench GUI, I plotted the closing price in green so the blue shaded area above it (upper value) shows the moving standard deviation. Thus half the variances shown would yield values above or below the moving average for predictive purposes.std_devThis BIRT chart — generated with real-time CoSort (SortCL) data preparation — shows the relative daily volatility of Dow Jones closing prices in the third quarter of 2013, via the standard deviation from its moving 20-day average.

Print Friendly

{ 2 comments… read them below or add one }

mel December 15, 2016 at 7:19 am

More examples?

And what about a standard deviation with conditions?



David Friedland July 11, 2017 at 11:00 am

Sorry for a delayed reply to this inquiry, Mel. Yes, you can apply conditions as WHERE clauses in aggregation logic like this. Please email with your requirements if you’d like a job sample.


Leave a Comment

Previous post:

Next post: