Question

I know the procedure of transforming one distribution to another by the use of CDF. However, I would like to know if there is existing function in Matlab which can perform this task?

My another related question is that I computed CDF of my empirical using ecdf() function in Matlab for a distribution with 10,000 values. However, the output that I get from it contains only 9967 values. How can I get total 10,000 values for my CDF? Thanks.

Was it helpful?

Solution 2

for t=1:nT 
    [f_CDFTemp,x_CDFTemp]=ecdf(uncon_noise_columndata_all_nModels_diff_t(:,1,t)); % compute CDF of empirical distribution
    f_CDF(1:length(f_CDFTemp),t) = f_CDFTemp; % store the CDF of different distributions with unequal size in a new variable
    x_CDF(1:length(x_CDFTemp),t) = x_CDFTemp;
    b_unifdist=4*t;
    [Noise.N, Noise.X]=hist((a_unifdist+(b_unifdist-a_unifdist).*f_CDF(:,t)),100); % generate the uniform distribution by using the CDF of empirical distribution as the CDF of the uniform distribution
    generatedNoise(:,:,t)=emprand(Noise.X,nRows,nCol); % sample some random numbers from the uniform distribution generated above by using 'emrand' function
end

OTHER TIPS

As you say, all you need is the CDF. The CDF of a normal distribution can be expressed in terms of the erf Matlab function.

Untested example:

C = @(x)(0.5 * (1 + erf(x/sqrt(2))));

x = randn(1,1000);  % Zero-mean, unit variance
y = C(x);           % Approximately uniform

This is not exactly what you are looking for, but it shows how to do the opposite. Reversing it should not be that bad.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top