How to use the simple-statistics.linearRegressionLine function in simple-statistics

To help you get started, we’ve selected a few simple-statistics examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github funkeinteraktiv / cogran / lib / methods / linear-regression.js View on Github external
var distinct = [];
  for(var i=0; i< regressionData.length; i++){
	  if (distinct.includes(regressionData[i][0]) == false){
		distinct.push(regressionData[i][0]);
	  }
  }

  for(var i=0; i< distinct.length; i++){
	  this['class' +i] = [];
	  for(var j=0; j< regressionData.length; j++){
		if(regressionData[j][0] == distinct[i]){
		  this['class' +i].push(new Array(regressionData[j][1], regressionData[j][2]));
	    }
	  }

	  this['regressionLine' +i] = SiSt.linearRegressionLine(SiSt.linearRegression(this['class' +i]));
  }

  for(var i=0; i< distinct.length; i++){
	  this['Atsc' +i] = [];
	  for(var j=0; j< Atsc.features.length; j++){
		  if(Atsc.features[j].properties.class == distinct[i]){
			  Atsc.features[j].properties.Ptx = this['regressionLine' +i](Atsc.features[j].properties.Atsc);
		  }
	  }
  }

  target.features.forEach(d => {
	d.properties.Pt = 0;

	for(var i=0; i< Atsc.features.length; i++){
		if(Atsc.features[i].properties.targetId == d.properties.targetId){
github cloudkeeper-io / cloudkeeper-ui / src / components / data-cards / trends-card / trends-card.utils.tsx View on Github external
export const getGraphData = (data: any, activeIndex: number) => {
  const { dateField, valueField } = TRENDS[activeIndex]
  const formattedCostData = map(data, (x) => ({ date: DateTime.fromISO(x[dateField]).valueOf(), value: x[valueField] }))
  const regressionData = map(formattedCostData, (x) => [x.date, x.value])
  const regression = linearRegression(regressionData)
  const lineFn = linearRegressionLine(regression)

  return map(formattedCostData, (x, index) => ({ ...x, trendData: lineFn(first(regressionData[index])) }))
}