Wednesday, 24 February 2016

ssci.js version 1.2.1

I’ve updated the JavaScript library to version 1.2.1. The only changes from v1.2.0 is the addition of a gain function and phase shift function for the filter smoothing function.

Change to Kernel Smoother

Introduction

I recently changed a whole load of the functions in the ssci JavaScript library. One of these changes was the way that the kernel smoothing function worked.

The previous function was fairly slow and didn’t scale particularly well. In fact, the main loop of the function would suggest that it scales as O(n^2).

I therefore decided to make a change to the function. Instead of looping over every point and then calculating the weight at every other point, I’ve changed it so that:
  • It loops through every point similarly to the previous function
  • Then for point n it calculates the weight at the central point (i.e. point n)
  • It then loops through every point lower (in the array) than n and calculates the weight. If the weight of this point is lower than a certain threshold to the central point, then the loop ends.
  • It then loops through every point higher (in the array) than n and calculates the weight. If the weight of this point is lower than a certain threshold to the central point, then the loop ends.

The default setting of the threshold is 0.001 (i.e. 0.1%). The way the function operates though does mean two assumptions have been made.
  • The data has already been ordered in the x-coordinate within the array.
  • The kernel function being used must always decrease from the central point beyond this threshold.
The rest of this entry can be read on my new blog...

Tuesday, 23 February 2016

SurveyScience JavaScript Library


I’ve been converting some of the functions from the Excel add-in to Javascript functions within a library. It’s finally ready for release and can be found here.

It contains functions to:
  • Smooth data
  • Deseasonalise data
  • Perform least squares regression
  • Exponential smoothing
  • Create auto-correlation and partial auto-correlation plots
  • Market research functions
  • Utility functions to modify arrays

There’s still some work to do on it but it can be used as is – go to the above link for more details.

I originally started it to created some smoothed lines for some D3 charts.

Hopefully it will prove useful.

Website refreshed

In the process of reprogramming the Excel add-in, I’ve also refreshed my website.
Everything bar the articles have been changed, I think.
I’ve also released a JavaScript version of some of the functions in the add-in. I’ll post about it fully later on but if you want to take a look go here.

Wednesday, 9 December 2015

Wordpress blog

I've now added a wordpress blog to my website. It doesn't have many entries on it at the moment but I'll be updating that one from now on rather than this one, I think.

Wednesday, 21 October 2015

American Football Statistics part 2

In the last post, I went through an interesting (for me anyway) observation from a book on the proportion of wins for American football teams. I only gave a chart for the example of the Buffalo Bills team.

Well, I've now put the data together for the rest of the teams and placed it on my site. You can now look at the stats for the rest of the teams:


Or at least those teams that have data from 1960 to 2014. I still find it hard to find much periodicity in quite a few of the teams. And some teams have some quite lengthy periods of high win percentages (San Francisco 49ers):


It's only to be expected that there would be some exceptions. What I should do if I wanted to 'prove' it one way or the other is to calculate the periodicity for each team and then see what correlation we get. Next time maybe.

Data courtesy of www.pro-football-reference.com
Charts courtesy of D3 (www.d3js.org)

Monday, 19 October 2015

American Football Statistics

Recently I've been reading a book about how mathematical our everyday lives are (Towing Icebergs, falling dominoes and other adventures in applied mathematics by Robert B. Banks). In this book the author has an interesting chapter dedicated to the statistics of America football.

In this chapter he uses the data from the performances of the NFL teams from 1960 to 1992 to suggest that a first order linear discrete delay differential equation can be used to model the teams winning record for each season and that the performance is periodic with a specific time between each peak in the percentage of wins for that season.

The rationale is that (basically) the performance of the team from the previous season dictates the order (in reverse) of selection of new talent for the upcoming season.

The equation he derives is:
dU(t)/dt=a[U_m-U(t-τ)]

where U(t) is the proportion of wins in each season, U_m is the league wide average value of U and a is the growth coefficient.

Irritatingly he says that there are many ways to solve the equation but then uses an approximate, 'risky' method to produce a solution (Taylor series expansion in case you're wondering). He does however provide references so that you can follow up on the details.

The example he goes through in most detail is that of the Buffalo Bills. The graph of their performance for the years in question is below (thanks to this site for the data). It does indeed seem to be periodic between the years he mentioned.



This seemed odd to me. Obviously you wouldn't be able to determine the exact rank of each team in each year but you would know which teams were likely to be going down or up the rankings. You'd be able to tell, for example, that if your team did well one season, then they were likely to do less well the next.

However, when you look at the data for subsequent years the pattern was hard to determine. It seemed that the Bills were on a consistent downward trend after this. Although given the volatility of the data it's possible that a lot of frequencies would fit this chart.

Has something changed in the way selection is now carried out? I don't know. Is the pattern that he spotted (or at least went through) the same for other teams throughout this time period? Does it also change after 1992?

I'll follow it up by looking at all the teams that were around between 1960 and 1992 next time.