error in chi2gof: a Non-scalar arguments must match in size.
5 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I've crated an lognormal distribution for my Data 'Var' and calculated mu and sigma using the mle funktion.
[phat,pci] = mle(Var,'Distribution','Lognormal','Alpha',0.01);
params.l = phat;
sicherheit.l = pci;
Now I want to use the chi2gof funtion to evaluate my fit.
%chi quadrat test
[hl,pl] = chi2gof(Var,'CDF',{@logncdf,'mu',params.l(1),'sig',params.l(2)});
But I get the error:
Error using chi2gof (line 235)
Error evaluating cdf function 'logncdf'.
Error in VerteilungsfunktionFINO1 (line 68)
[hl,pl] = chi2gof(Var,'CDF',{@logncdf,'mu',params.l(1),'sig',params.l(2)});
Caused by:
Error using logncdf>locallogncdf (line 84)
Non-scalar arguments must match in size.
Any Ideas? Thanks.
0 Commenti
Risposte (1)
Brahmadev
il 10 Nov 2023
I understand that you would like to call the "chi2gof" function, but you are facing the error mentioned in the question This is due to the use of “Name-Value” pair in the call to “chi2gof” function handle, the code can be modified as shown below for resolving this issue. I have added some sample data for "Var" to test the output.
% Generating random lognormal data for "Var" to test the output
rng(42); % Set the random seed for reproducibility
mu = 1.5; % Mean of the underlying normal distribution
sigma = 0.8; % Standard deviation of the underlying normal distribution
n = 100; % Number of samples
Var = random('logn', mu, sigma, [n, 1]);
[phat,pci] = mle(Var,'Distribution','Lognormal','Alpha',0.01);
params.l = phat;
sicherheit.l = pci;
%chi quadrat test
[hl,pl] = chi2gof(Var,'CDF',{@logncdf, params.l(1), params.l(2)});
For more information, you can refer to the following section in the "chi2gof" documentation: https://www.mathworks.com/help/stats/chi2gof.html#d126e181826:~:text=h%20%3D%20chi2gof(x%2C%27cdf%27%2C%7B%40normcdf%2Cmean(x)%2Cstd(x)%7D)
Hope this helps in resolving your issue!
0 Commenti
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!