How to simulate the outage probability using Matlab?

Can any one help me ?? i want to simulate my CDF (or outage) equation and i have never done the simulation before, can anyone send me a sample code on Matlab to learn how to do it?

回答 (1 件)

the cyclist
the cyclist 2016 年 12 月 17 日

0 投票

Does the answer to this question help you?

5 件のコメント

Deema42
Deema42 2016 年 12 月 17 日
編集済み: Deema42 2016 年 12 月 17 日
Thank you for your reply. Unfortunately, no!. i use Matlab very well, but i'm still a beginner on the simulation, so i need a good written code to learn from.
the cyclist
the cyclist 2016 年 12 月 17 日
In that case I suggest you
  • Give significantly more detail about what you are trying to do
  • Show the code that you have tried to write, so we can help you
Deema42
Deema42 2016 年 12 月 18 日
編集済み: Deema42 2016 年 12 月 18 日
N = 1000;
mu = -1;
sigma = 5;
X = mu + sigma*randn(N,1);
% Points for which CDF and PDF are to be evaluated
x = linspace(-10,10,1000); % Theoretical PDF and CDF
fx = (1/sqrt((2*pi*sigma*sigma)))*exp(-(((x - mu).^2)/(2*sigma*sigma))); Fx = 0.5*(1 + erf((x - mu)/(sqrt(2*sigma*sigma)))); % Estimate PDF and CDF
[f,F] = EstimateDistribution(X,x); % Plot Results
figure(2); plot(x,f,x,fx,x,F,x,Fx); xlabel('x'); ylabel('PDF & CDF'); str1 = strcat('Simulated PDF;','Area = ',num2str(trapz(x,f))); str2 = strcat('Theoretical PDF;','Area = ',num2str(trapz(x,fx))); legend(str1,str2,'Simulated CDF','Theoretical CDF','Location','northwest');% code
Deema42
Deema42 2016 年 12 月 18 日
function [f,F] = EstimateDistribution(X,x) % Checking Input Arguments if nargin<2||isempty(x), x = linspace(-10,10,1000);end if nargin<2||isempty(X) error('Missing Input Arguments: Please specify vector random variables'); end
% Impelementation Starts Here f = zeros(1,length(x)); % Preallocation of memory space F = f; % Preallocation of memory space h = 0.000000001; % Small value closer to zero for evaluating % numerical differentiation.
% Estimating CDF by its definition for m = 1:length(x) p = 0; % True Probability q = 0; % False Probability for n = 1:length(X) if X(n)<=x(m) % Definition of CDF p = p + 1; else q = q + 1; end end F(m) = p/(p + q); % Calulating Probability end
% Estimating PDF by differentiation of CDF for k = 1:length(x) fxph = interp1(x,F,x(k) + h,'spline'); % Interpolating value of F(x+h) fxmh = interp1(x,F,x(k) - h,'spline'); % Interpolating value of F(x-h) f(k) = (fxph - fxmh)/(2*h); % Two-point formula to compute end % Numerical differentiation f = smooth(f);
Deema42
Deema42 2016 年 12 月 18 日
編集済み: Deema42 2016 年 12 月 18 日
sorry for the delay, these are two codes i found on Mathworks, they are fine, i want to do exactly like this but for a different PDF and CDF, mine is for cascaded Rician random variable, so the pdf is different than a normal rician. how can i modify this code?? if you like, i can send you my PDF and CDF equations.

サインインしてコメントする。

質問済み:

2016 年 12 月 17 日

編集済み:

2016 年 12 月 18 日

Community Treasure Hunt

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

Start Hunting!

Translated by