# 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.

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

for(var i=0; i&lt; distinct.length; i++){
this['class' +i] = [];
for(var j=0; j&lt; 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&lt; distinct.length; i++){
this['Atsc' +i] = [];
for(var j=0; j&lt; 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 =&gt; {
d.properties.Pt = 0;

for(var i=0; i&lt; Atsc.features.length; i++){
if(Atsc.features[i].properties.targetId == d.properties.targetId){``````
cloudkeeper-io / cloudkeeper-ui / src / components / data-cards / trends-card / trends-card.utils.tsx View on Github
``````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])) }))
}``````

## simple-statistics

Simple Statistics

ISC