To perform a Kolmogorov-Smirnov test for goodness of fit in Matlab, you can use the built-in function kstest
. The kstest function tests whether the sample data comes from a specified continuous distribution, or from a normal distribution with a specified mean and standard deviation.
Here's an example use of the kstest
function:
main.m596 chars18 lines
In this example, the null hypothesis is that the sample data comes from a normal distribution with mean=0 and standard deviation=1. The kstest
function returns a p-value, which we can use to make a decision about whether to reject the null hypothesis. If the p-value is less than the significance level (e.g. 0.05), we can reject the null hypothesis and conclude that the sample data is not consistent with the specified distribution.
gistlibby LogSnag