Skip to content

Instantly share code, notes, and snippets.

@sbyrnes
sbyrnes / gist:2797579
Created May 27, 2012 02:46
Usage of Lyric
var data = applyModel(model, estimationInput);
@sbyrnes
sbyrnes / gist:2797461
Created May 27, 2012 02:45
Building a model in Lyric
var model = buildModel(input);
@sbyrnes
sbyrnes / gist:2797345
Created May 27, 2012 02:44
Lyric input format
var input = new Array();
input['x'][0] = 1; input['y'][0] = 0.5;
input['x'][1] = 2; input['y'][1] = 1.6;
input['x'][2] = 3; input['y'][2] = 4.5;
input['x'][3] = 4; input['y'][3] = 7.6;
input['x'][4] = 5; input['y'][4] = 10.1;
@sbyrnes
sbyrnes / gist:2797087
Created May 27, 2012 02:41
Implementation of the Normal Equation
// FORMULA: theta = pinv(X'*X)*X'*y;
function generateTheta(X, y)
{
// Get the transpose of X
Xt = X.transpose();
// Multiple X by its transpose
var Xmain = X.x(Xt);
// Get the inverse of the result of multiplying X by its transpose
@sbyrnes
sbyrnes / gist:2796914
Created May 27, 2012 02:39
Example use of Lyric
var input = new Array();
input['x'][0] = 1; input['y'][0] = 0.5;
input['x'][1] = 2; input['y'][1] = 1.6;
input['x'][2] = 3; input['y'][2] = 4.5;
input['x'][3] = 4; input['y'][3] = 7.6;
input['x'][4] = 5; input['y'][4] = 10.1;
var estimationInput = new Array();
estimationInput['x'][0] = 6;
estimationInput['x'][1] = 7;
[FlurryAppCircle setAppCircleEnabled:YES];
// pointer into the AppCircle library
static NSObject *gAppCircleDelegate = nil;
// if AppCircle is enabled, pass the ad data buffer to it and parse it
if(gAppCircleDelegate != nil) {
if ([gAppCircleDelegate respondsToSelector:@selector(parseData:bufferLength:)]) {
pCurBufferPos = (char *)[gAppCircleDelegate parseData:pDataBuffer bufferLength:remainingBufferLength];
} else { // throw some exception }
}