I wanted to apply the chi-squared function with the return of the p-value, but matlab's chi2cdf function only returns zero.
Mostra commenti meno recenti
% Example data matrix (2000 rows and 9 columns)
data_matrix = randi([0, 10], 2000, 9); % Replace this with your actual data
% Example empirical frequency (a vector with 9 elements)
empirical_frequency = [10, 20, 30, 40, 50, 60, 70, 80, 90]; % Replace this with your actual empirical frequency
% Initialize vectors to store results
chi_squared_results = zeros(2000, 1);
p_values = zeros(2000, 1);
for i = 1:2000
% Select the data for row i
row_i = data_matrix(i, :);
% Calculate the chi-squared statistic manually
chi_squared = sum((row_i - empirical_frequency).^2 ./ empirical_frequency);
% Determine the degrees of freedom (df)
df = length(row_i) - 1;
% Calculate the p-value using the chi-squared distribution
p = 1 - chi2cdf(chi_squared, df);
% Store the results in vectors
chi_squared_results(i) = chi_squared;
p_values(i) = p;
end
unique(p_values)
The problem is that chicdf return 0.
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Hypothesis Tests in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

