
给出一组值 ,其中y是从某一总体抽出的一组样本容量为n的随机数。如何求图片中的第二个方程的 。自己的想法是利用fsolve函数来求出 。具体做法:
- Lambda=6;beta=8;%给出关于lamda和beta的初值;
- u = rand(1,100);
- y=sqrt(0.5*log(2)-0.5*log(log(exp(2)-(exp(2)-1).*u)));%从服从某一分布的总体中抽取容量为n=100样本,记为y.
[color=rgb(51, 102, 153) !important]复制代码
图片中的第二个方程为
- function f=funRPL(Lambda,beta,y)
- syms x;
- n=length(y);
- f=x-(1-exp(-x))*sum(1+lambda*exp(-beta*y.^2))/n;
- end
[color=rgb(51, 102, 153) !important]复制代码
然后想用z=fsolve('funRPL',0.5),解出x即)
但是运行报错:
- >> z=fsolve('funRPL',0.5)
- ??? Input argument "y" is undefined.
- Error in ==> funRPL at 3
- n=length(y);
- Error in ==> fsolve at 180
- fuser = feval(funfcn{3},x,varargin{:});
[color=rgb(51, 102, 153) !important]复制代码
已经困扰很长时间,不知道为甚什么? |
|
|