无法从函数确定的值A,cB和C的标准错误

时间:2022-05-22 15:49:10

For the code below, I can't get a standard error for the individual values of A, B, and C. I've tried a few different ways, and either come up with 0 or with a singular value. The method below is the latest way I tried but which didn't work. Does anyone have any suggestions? I am new to Python.

对于下面的代码,我无法得到A,B和C各个值的标准误。我尝试了几种不同的方法,并提出0或具有奇异值。下面的方法是我尝试过的最新方法,但是没有用。有没有人有什么建议?我是Python的新手。

import numpy as np
import pandas as pd
import scipy
import pylab
import matplotlib
import matplotlib.pyplot as plt
import math
import sympy as sp
from scipy.optimize import curve_fit
x = np.array([600,650,700,750,800,850,900,950,1000])
y = np.array([.124,.627,2.492,8.187,23.06,57.24,127.9,261.6,496.5])
lny = np.log(y)
plt.plot(x,lny,'.')
plt.show()
def func(x,a,b,c):
    return a+b/x+c*np.log(x)
popt, pcov = curve_fit(func,x,lny)
print popt
a,b,c = (popt)
print a
print b
print c
stdvfunc = np.std(func(x,a,b,c))
print stdvfunc

1 个解决方案

#1


0  

The standard deviations of a, b, and c are

a,b和c的标准偏差是

pcov[0,0]**0.5
pcov[1,1]**0.5 #and 
pcov[2,2]**0.5

respectively.

The documentation is referenced and copied below. See the bold italicized text.

下面引用并复制文档。请参阅粗体斜体文本。


https://docs.scipy.org/doc/scipy/reference/generated/scipy.optimize.curve_fit.html

pcov : 2d array

pcov:2d数组

The estimated covariance of popt. The diagonals provide the variance of the parameter estimate. To compute one standard deviation errors on the parameters use

估计的popt协方差。对角线提供参数估计的方差。要计算参数使用的一个标准偏差

perr = np.sqrt(np.diag(pcov)).

How the sigma parameter affects the estimated covariance depends on absolute_sigma argument, as described above.

sigma参数如何影响估计的协方差取决于absolute_sigma参数,如上所述。

If the Jacobian matrix at the solution doesn’t have a full rank, then ‘lm’ method returns a matrix filled with np.inf, on the other hand ‘trf’ and ‘dogbox’ methods use Moore-Penrose pseudoinverse to compute the covariance matrix.

如果解的雅可比矩阵没有满秩,那么'lm'方法返回一个填充np.inf的矩阵,另一方面'trf'和'dogbox'方法使用Moore-Penrose伪逆来计算协方差矩阵。

#1


0  

The standard deviations of a, b, and c are

a,b和c的标准偏差是

pcov[0,0]**0.5
pcov[1,1]**0.5 #and 
pcov[2,2]**0.5

respectively.

The documentation is referenced and copied below. See the bold italicized text.

下面引用并复制文档。请参阅粗体斜体文本。


https://docs.scipy.org/doc/scipy/reference/generated/scipy.optimize.curve_fit.html

pcov : 2d array

pcov:2d数组

The estimated covariance of popt. The diagonals provide the variance of the parameter estimate. To compute one standard deviation errors on the parameters use

估计的popt协方差。对角线提供参数估计的方差。要计算参数使用的一个标准偏差

perr = np.sqrt(np.diag(pcov)).

How the sigma parameter affects the estimated covariance depends on absolute_sigma argument, as described above.

sigma参数如何影响估计的协方差取决于absolute_sigma参数,如上所述。

If the Jacobian matrix at the solution doesn’t have a full rank, then ‘lm’ method returns a matrix filled with np.inf, on the other hand ‘trf’ and ‘dogbox’ methods use Moore-Penrose pseudoinverse to compute the covariance matrix.

如果解的雅可比矩阵没有满秩,那么'lm'方法返回一个填充np.inf的矩阵,另一方面'trf'和'dogbox'方法使用Moore-Penrose伪逆来计算协方差矩阵。