Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Python-Programs-for-Nonlinear-Dynamics/UserFunction.py
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
28 lines (18 sloc)
432 Bytes
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
#!/usr/bin/env python3 | |
# -*- coding: utf-8 -*- | |
""" | |
Created on Sun May 12 12:33:27 2019 | |
@author: nolte | |
""" | |
import numpy as np | |
from scipy import integrate | |
from matplotlib import pyplot as plt | |
import networkx as nx | |
def linfit(x,y): | |
meanx = np.mean(x) | |
meany = np.mean(y) | |
meanxy = np.mean(x*y) | |
meanx2 = np.mean(x**2) | |
m = (meanxy - meanx*meany)/(meanx2 - meanx**2) | |
b = meany - m*meanx | |
return m, b | |