Which should I use for this integration.

1 visualizzazione (ultimi 30 giorni)
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 Commenti
Navya Seelam
Navya Seelam il 16 Mag 2020
Hi,
The integral function you are using is correct. I recommend to recheck your logic.

Accedi per commentare.

Risposte (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by