# PetscLinearRegression
Gives the best least-squares linear fit to some x-y data points 
## Synopsis
```
PetscErrorCode PetscLinearRegression(PetscInt n, const PetscReal x[], const PetscReal y[], PetscReal *slope, PetscReal *intercept)
```

## Input Parameters

- ***n -*** The number of points
- ***x -*** The x-values
- ***y -*** The y-values



## Output Parameters

- ***slope     -*** The slope of the best-fit line
- ***intercept -*** The y-intercept of the best-fit line





## See Also
 `PetscConvEstGetConvRate()`

## Level
intermediate

## Location
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/sys/utils/mathfit.c.html#PetscLinearRegression">src/sys/utils/mathfit.c</A>


---
[Edit on GitLab](https://gitlab.com/petsc/petsc/-/edit/release/src/sys/utils/mathfit.c)


[Index of all Sys routines](index.md)  
[Table of Contents for all manual pages](/docs/manualpages/index.md)  
[Index of all manual pages](/docs/manualpages/singleindex.md)  
