# How to plot the outage probability?

**URL:** <https://community.wolfram.com/t/how-to-plot-the-outage-probability/406>\
**Category:** Questions\
**Tags:** mathematica, graphics-and-visualization, statistics-and-probability\
**Created:** [August 18, 2013, 3:33pm UTC](https://community.wolfram.com/t/how-to-plot-the-outage-probability/406 "2013-08-18T15:33:49Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![yahiaalghorani](https://avatars.discourse-cdn.com/v4/letter/y/bcef8e/32.png) [@yahiaalghorani](https://community.wolfram.com/u/yahiaalghorani)\
**Post date:** [August 18, 2013, 3:33pm UTC](https://community.wolfram.com/t/how-to-plot-the-outage-probability/406/1 "2013-08-18T15:33:49Z")

</div>

How to plot the outage probability (f) of the gamma function in empirical distribution (by simulation) and theoretical distribution in the same figure for comparison purpose

```auto
f = 1 - Gamma[m, (m ((2^(2 R) - 1)/S)^(1/n))/ t] (Gamma[m, (m ((2^(2 R) - 1)/S)^(1/n))/t]/Gamma[m]^2)
Plot[f, {S, 0, 7}]

```

we assume that R=1, n=3, m=1, t=1

---

<div class="post-metadata">

**Author:** ![sghuisman](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/sghuisman/32/27850_2.png) [@sghuisman](https://community.wolfram.com/u/sghuisman)\
**Post date:** [August 18, 2013, 5:17pm UTC](https://community.wolfram.com/t/how-to-plot-the-outage-probability/406/2 "2013-08-18T17:17:15Z")

</div>

This should work:

```auto
f=1-Gamma[m,(m ((2^(2 R)-1)/S)^(1/n))/t] (Gamma[m,(m ((2^(2 R)-1)/S)^(1/n))/t]/Gamma[m]^2)
Plot[f/.{m->1,t->1,n->3,R->1},{S,0,7}]

```

You have to substiture values for m,t,n,R otherwise you can’t plot it.

---

<div class="post-metadata">

**Author:** ![yahiaalghorani](https://avatars.discourse-cdn.com/v4/letter/y/bcef8e/32.png) [@yahiaalghorani](https://community.wolfram.com/u/yahiaalghorani)\
**Post date:** [August 19, 2013, 5:04am UTC](https://community.wolfram.com/t/how-to-plot-the-outage-probability/406/3 "2013-08-19T05:04:51Z")

</div>

Thanks for your interest, but my enquiry is about the comparison between analytical results with simulation results such as the below graph as an example:

 ![picture.jpg](https://global.discourse-cdn.com/wolfram/original/3X/4/f/4f18e386cd5a6bf9203956513e4b8a95f73d10b5.jpeg)

---

<div class="post-metadata">

**Author:** ![giulioa](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/giulioa/32/18527_2.png) [@giulioa](https://community.wolfram.com/u/giulioa)\
**Post date:** [August 20, 2013, 4:00pm UTC](https://community.wolfram.com/t/how-to-plot-the-outage-probability/406/4 "2013-08-20T16:00:53Z")

</div>

What about something like

```auto
f[m_, S_] := 
 With[{ R = 1, n = 3, t = 1}, 
  1 - Gamma[
     m, (m ((2^(2 R) - 1)/S)^(1/n))/
      t] (Gamma[m, (m ((2^(2 R) - 1)/S)^(1/n))/t]/Gamma[m]^2)]

data = Table[{S, f[#, S] + RandomReal[{-1, 1}]/100}, {S, 0.01, 
      7, .1}] & /@ {1, 2, 3};

Show[
 Plot[Evaluate[f[#, S] & /@ {1, 2, 3}], {S, 0, 7}],
 ListPlot[data]
 ]

```

 ![3066plot.png](https://global.discourse-cdn.com/wolfram/original/3X/1/7/170d9d945f0fcfdd6a2a9ae9b69252815e7550bb.png)

---

<div class="post-metadata">

**Author:** ![pavlyk](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/pavlyk/32/7510_2.png) [@pavlyk](https://community.wolfram.com/u/pavlyk)\
**Post date:** [August 20, 2013, 4:51pm UTC](https://community.wolfram.com/t/how-to-plot-the-outage-probability/406/5 "2013-08-20T16:51:18Z")

</div>

In the probability speak, the function f is known as a SurvivalFunction. We can define the probability distribution, describing the outage characteristics (either a duration, or an onset, you are not being specific) as

```auto
In[80]:= f = (FullSimplify[#1, S > 0] & )[
FunctionExpand[With[{R = 1, n = 3, m = 1, t = 1},
1 - Gamma[m, (m*((2^(2*R) - 1)/S)^(1/n))/t]*(Gamma[m, (m*((2^(2*R) - 1)/S)^(1/n))/t]/Gamma[m]^2)]]]

Out[80]= 1 - E^(-((2*3^(1/3))/S^(1/3)))

In[81]:= odist =
ProbabilityDistribution[{"SF", f}, {S, 0, Infinity}];

```

We can now sample from this distribution using RandomVariate:

```auto
sample = RandomVariate[dist, 10^6];

```

The distribution has heavy-tail:

```auto
In[52]:= Probability[x > 1000, x \[Distributed] sample] // N

Out[52]= 0.24759

```

Here we plot a histogram of the data, displaying the logarithm of the probability density function:

```auto
hist = Histogram[sample, {0, 1000, 1}, "LogPDF"];
plot = Plot[Log@PDF[TruncatedDistribution[{0, 1000}, dist], S] // Evaluate, {S, 0.1, 1000}, PlotRange -> All, PlotStyle -> Thick, Exclusions -> None];
Show[hist, plot]

```

Here is a screen-shot:

 ![Capture.PNG](https://global.discourse-cdn.com/wolfram/original/2X/b/b3cdd00134a68bf8d65dbd599b06ed285fb4a62c.png)

---

<div class="post-metadata">

**Author:** ![yahiaalghorani](https://avatars.discourse-cdn.com/v4/letter/y/bcef8e/32.png) [@yahiaalghorani](https://community.wolfram.com/u/yahiaalghorani)\
**Post date:** [August 31, 2013, 8:18pm UTC](https://community.wolfram.com/t/how-to-plot-the-outage-probability/406/6 "2013-08-31T20:18:40Z")

</div>

Hi Oleksandr,

In fact, I am willing to inquire if I can plot the following function with scattered data instead of histogram graph as I want to compare this with the analytical graph below

```auto
f = Product[1 - (Gamma[m, (m ((2.25)/10^(S/10))^(1/n))/\[CapitalOmega]] Gamma[m, (m ((1.5)/10^(S/10) )^(1/n))/\[CapitalOmega]])/ Gamma[m]^2, {i, 1, M}] /. Subscript -> Part;
ticks = {10^-4, 10^-3, 10^-2, 10^-1, 1};
LogPlot[f, {S, 0, 40}, PlotRange -> {10^-4, 1}, Ticks -> {Automatic, ticks}, GridLines -> Automatic, Frame -> True] 

```

Assuming that :

```auto
m=1, n=1, M=3, \[CapitalOmega] = 2

```

 ![plot.jpg](https://global.discourse-cdn.com/wolfram/original/3X/6/2/623c738efb69dc11601a67b56c121f3e6f6447e8.jpeg)
