#!/usr/bin/env perl from decimal import * # yi = 2xi - 1 def merit(y): n = len(y) e = Decimal(0) for k in range(1,n): t = 0 for i in range(0,n-k): t += y[i] * y[i+k] e += t ** 2 f = (n ** 2) / ( 2 * e) return(f) y = [1,-1,1,-1] print merit(y)