Archive for November 2008

alpha release

is an alpha release of a javascript version of Loglet Lab, which fits S-curves of the form:

For a demo, click the buttons labeled “step 1″, “step 2″, and “step 3″ (in that order). That will load the “classic” dataset on the growth of a sunflower, and fit a single S-shaped logistic to it. The data and plots all load on one page, so you have to keep scrolling down. There are other datasets pre-loaded. The data is “live” once loaded, so you can change values and click “step 3″ (fit) with new values.

This “app” is mainly to test browser support and work on the algorithms and plotting, with the eventual goal of turning this into a google spreadsheet widget, but it is actually usable on its own.

I am using a “new” constrained regression algorithm that is inefficient (but robust…). So you really need a cutting edge browser (i.e. google chrome, webkit nightly build, or Firefox 3.1 beta with JIT enabled). I don’t use Microsoft IE, so it probably won’t work on IE. I plan on explaining the regression algorithm in a later post.

This PDF explains a bit about the logistic formulation used and how we do our plots.

Matlab, jQuery and JSON

I do all my numerical algorithm development in Matlab, so I needed a way to easily get results from Matlab into javascript. Here is a (a pretty cool if I don’t say so myself) matlab code that creates a JSON file from a matlab data structure.

data.x = rand(10,1);
data.y = rand(10,1)

dataname = 'data' 

fid = fopen('matlab.json','w');

numdata = max(size(fieldnames(eval(dataname))))

fdata = char(fieldnames(eval(dataname)));

fprintf(fid,'{ "%s" : {\n ',dataname)
for dataiter=1:numdata,
  fprintf(fid,' "%s" : [ \n',fdata(dataiter));
  stmp = sprintf('%s.%s',dataname,fdata(dataiter));
  for i=1:(max(length(eval(stmp))))-1,
    stmp = sprintf('%s.%s(%i)',dataname,fdata(dataiter),i);
    fprintf(fid,'%1.10e , \n',eval(stmp));
  stmp2 =  sprintf('%s.%s',dataname,fdata(dataiter));;
  stmp = sprintf('%s.%s(%i)',dataname,fdata(dataiter),(max(length(eval(stmp2)))));
  fprintf(fid,'%1.10e  \n',eval(stmp));

  if dataiter == numdata ,
    fprintf(fid,'] \n');
    fprintf(fid,'], \n');


fprintf(fid,'} } \n');

And then reading it in and parsing it with jQuery is really simple.

 var x = [];
 var y = [];
 $.ajaxSetup({ async: false});
  $.getJSON("matlab.json", function (json)
              x =;
              y =;

Welcome to Loglet in the Clouds

I am currently (re)-writing the Loglet Lab¬†software application into a “cloud” application.¬† Basically, it means re-writing the algorithms in javascript, so that it is easy to plug into and “mash up” the Web 2.0 “cloud” (i.e. as a plug-in (gadget) for google spreadsheets).¬† As the code will be open source ( current license LPGL 2.1 ), I’ll post things that other users or developers of Loglet Lab Cloud edition might find useful.

Here is an example of a proof-of-concept google gadget for google spreadsheets, which uses the excellent flot plotting library for the jQuery framework: