需要对一个复杂的函数积分计算p-value,如下图
https://imgur.com/36989ip.jpg
其中G为卡方分配的cdf,Φ为标准常态分配的pdf
程式码如下
C=1; n=100; c1=1.15; alpha=0.05;Cp=C+0.12;
syms y;
f=(normpdf(y+3*(Cp-C)*n^0.5,0,1)+normpdf((y-3.*(Cp-C).*n^0.5),0,1)).*chi2cdf(((n-1)*((3*Cp*n^0.5-y).^2)/9*n*c1^2),n-1);
但会跳错误讯息
Unable to prove '(5819*(y - 168/5)^2)/4 < 0' literally. Use 'isAlways' to
test the statement mathematically.
另外也有用匿名函数试着写过
[email protected](y) normpdf(y+3*(Cp-C)*n^0.5,0,1)+normpdf((y-3.*(Cp-C).*n^0.5),0,1);
[email protected](y) chi2cdf(((n-1)*((3*Cp*n^0.5-y).^2)/9*n*c1^2),n-1);
[email protected](y) fY(y).*G(y);
pv=integral(GY,0,3*Cp*n^0.5)
但计算出来pv=1很明显是错的,不确定问题在哪边,来请教大家