Which should I use for this integration.
1 回表示 (過去 30 日間)
古いコメントを表示
Hello everyone
I have to make a function to calculate significance of given arrays (lets say FC = C12 which is 47X1 double)
The fucnction should look like
function alpha = significance (FC)
% Variable FC is consistant values coloum. For example FC = C12 will give the significane of C12 coloum.
n = length (FC); % Calculates the Number of consistent respondents (Nt)
x = sum (FC == mode (FC)); % Calculates the Number of respondents answered mode
p = 1/17; % Probability of selecting mode (Pi)
mu = n * p;
mu1 = n * (1-p);
sigma = sqrt (n. * p. * (1 - p)); % Standerd deviation
if n <= 20
i = 0;
syms i
alpha = symsum ((factorial (n) / (factorial (i) * factorial (ni)) * (1/17). ^ (i) * (1-1 / 17). ^ (ni)), i, 0 , x);
elseif n> 20
syms y
f = (- (y-mu). ^ 2) / (2 * sigma. ^ 2); % 5.05 is 2 * sigma ^ 2, & 2.7 = mu
fun = (1 / (sigma * 2.5)) * (exp (f)); % 0.2516 = 1 / (sigma * 2.5), e = 2.71
a = -inf;
b = x; % x; % number of respondent selected mode
alpha = int (fun, a, b);
%%% ^ Which Integration function should I use here?
end
The problem here is, when I am running the script in commond window seperatly with values given as comment, it give me the currect value.
>> syms y
f = (- (y-2.7). ^ 2) / (5.05); % 5.05 is 2 * sigma ^ 2, & 2.7 = mu
fun = (0.2516) * (exp (f)); % 0.2516 = 1 / (sigma * 2.5), e = 2.71
a = -inf;
b = 19; % x; % number of respondent selected mode
alpha = int (fun, a, b);
>> alpha
alpha =
(629 * 2020 ^ (1/2) * pi ^ (1/2) * (erf ((163 * 2020 ^ (1/2)) / 1010) + 1)) / 100000
>> ans = (629 * 2020 ^ (1/2) * pi ^ (1/2) * (erf ((163 * 2020 ^ (1/2)) / 1010) + 1)) / 100000
ans =
1.0021
But when I run it in function above, I am getting my answer '0',
For FC = C12,
n = 47
x = 19
I want to know if I am using currect integration function? If not then which one should I use.
Please currect me.
4 件のコメント
Navya Seelam
2020 年 5 月 16 日
Hi,
The integral function you are using is correct. I recommend to recheck your logic.
回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Calculus についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!