Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function calculateLinearFit(datapoints){
var data = [];
for(var j=0;j< datapoints.length;j++){
if(datapoints[j][0] !== null) {
data.push([j, datapoints[j][0]]);
}
}
var line = ss.linear_regression()
.data(data)
.line()
var gradient = ss.linear_regression()
.data(data)
.m()
//winston.info('stijgings percentage: ' + (line(data.length-1)-line(0))/ line(0)) / data.length * 100;
//winston.info('gradient: ' + gradient * 100);
//winston.info('line(0): ' + line(0));
//winston.info('line(data.length-1): ' + line(data.length-1));
/* if no valid number is calculated, return null*/
var result = !isNaN(Math.round(((((line(data.length-1)-line(0))/ line(0)) / data.length) * 100 * 100)* 100) / 100) ? Math.round(((((line(data.length-1)-line(0))/ line(0)) / data.length) * 100 * 100)* 100) / 100 : null;
return result;
tplot[0].shift();
tplot[1].shift();
var graphPoints = _.zip(tplot[0], tplot[1]);
var xs = {};
var regressionDataLabel = "regression";
xs[schemaName] = schemaName + "_x";
xs[regressionDataLabel] = regressionDataLabel + "_x";
var scatterPlotArray = transformCSVtoScatterPlot(csvData, schemaName, xIndex, yIndex);
var min = Math.min.apply(null, tplot[0]);
var max = Math.max.apply(null, tplot[0]);
/* jshint ignore:start */
var regressionEquation = stats.linear_regression().data(graphPoints).line();
var minRegressionY = regressionEquation(min);
var maxRegressionY = regressionEquation(max);
scatterPlotArray.push([regressionDataLabel, minRegressionY, maxRegressionY],
[regressionDataLabel + "_x", min, max]);
/* jshint ignore:end */
var types = {};
types[regressionDataLabel] = "line";
var chart = c3.generate({
bindto: ".visualization-view",
data: {
xs: xs,
// Data Format:
// y row ['dataname', num, num, ...]
function shiftRegression(shiftingArray){
//construct input output pairs for regression based on shifting array
var localIOPairs = [];
for(var i =0; i < shiftingArray.length; i+=2){
var tmp = [];
for (var j =0; j
function linearRegression(ipoppw){
var linear_regression_line = ss.linear_regression()
.data(ipoppw).line();
return linear_regression_line;
}
function linearRegressionOverVectors(inputOututPairs){
var finalResultVector= [];
for (var k =0; k < inputOututPairs.length-1; k++){
var pwDataResult = constructPairWiseData(inputOututPairs[k],inputOututPairs[k+1]);
var linear_regression = ss.linear_regression()
.data(pwDataResult);
finalResultVector.push(linear_regression.m());
}
return finalResultVector;
}
function lengthRegression(inputOututPairs){
var lengthRegressionInput = [[]];
for(var i=0; i < inputOututPairs.length-1; i+=2){
lengthRegressionInput.push([inputOututPairs[i].length,inputOututPairs[i+1].length]);
}
lengthRegressionInput.shift();
var linear_length_regression = ss.linear_regression()
.data(lengthRegressionInput);
return linear_length_regression;
}
function linearRegressionOverVectors(inputOututPairs){