问题
I am trying to fit a exponential decay
to some experimental data and using polyfit in numpy. Also, fit itself is weighted, that is every data point has some weight associated with it and the polyfit function can find that optimal weights
?
Referred: Constrained np.polyfit
So final output would be coefficient value
and the weight vector
for every associated data points.
Also I want to constrain M
parameter between 0.9 to 1 and N
to -0.001 to -0.009
Data:
t(x) rate(y)
0 0.950
1 0.940
2 0.931
3 0.921
4 0.912
5 0.902
6 0.893
7 0.884
8 0.875
9 0.866
10 0.857
11 0.849
12 0.840
13 0.831
14 0.823
15 0.814
16 0.806
17 0.798
18 0.790
19 0.782
20 0.774
21 0.766
22 0.758
23 0.750
24 0.743
25 0.735
26 0.728
27 0.720
28 0.713
29 0.705
30 0.698
I want to fit the closest exponentialcurve to this data.
My approach:
def fit_exp_linear(x, y):
y = np.log(y)
M, N_log = np.polyfit(t, y, 1)
N = np.exp(N_log)
return M, N
How can I learn weight for every rows here?
Final output that I want is : M, N and Weights vector of size dim(x)
Outliers:
Is there way to do it?
How to get rid of these outliers using curve_fit?
来源:https://stackoverflow.com/questions/61281011/how-to-learn-or-find-weight-vector-and-remove-outliers-for-all-data-point-using