This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- This code is based on my other Gist "Simple linear regression in Javascript" (https://gist.github.com/patrickpissurno/ea0dc4039f075fbaf398619761bd9044) | |
-- There might be a more efficient way to do this in SQL | |
-- This function is resposible for computing the weights for the ax + b equation | |
CREATE OR REPLACE FUNCTION linear_regression(x_array decimal(15,2)[], y_array decimal(15,2)[]) RETURNS decimal(15,2)[] AS $$ | |
DECLARE | |
slope decimal(15,2); | |
intercept decimal(15,2); | |
n integer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function linear_regression(x_array, y_array){ | |
var slope; | |
var intercept; | |
var n = y_array.length; | |
var sum_x = 0; | |
var sum_y = 0; | |
var sum_xy = 0; | |
var sum_xx = 0; | |
var sum_yy = 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Work derived from https://github.com/sebarmeli/JS-Redirection-Mobile-Site | |
function IsMobile() | |
{ | |
// Helper function for adding time to the current date -> used by cookie | |
var addTimeToDate = function(msec) | |
{ | |
var exdate = new Date(); | |
exdate.setTime(exdate.getTime() + msec); | |
return exdate; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- | |
Conteúdo derivado de https://gist.github.com/letanure/3012978 | |
Cidades do Brasil em Android Resource String-Array | |
Brazil's Cities in Android String-Array Resource format | |
Free for use, no attribution required | |
--> | |
<resources> | |
<string-array name="cities_array"> | |
<item>Abadia de Goiás</item> |