penelope
penelope

Reputation: 15

Markov Inequality Plot in R

I have a Normal distribution CCDF plot made in R. I need to apply Markov inequality to this data and plot them at this same plot. How can I implement it? Any help is welcome.

My data and what I have:

n01 <- rnorm(1000, mean = 27947623, sd = 575.839)
ecdf_n01 <- ecdf(n01)
ccdf <- data.frame(x = sort(n01),
                 y = 1-ecdf_n01(sort(n01)))
plot(ccdf)

The Markov inequality formula:

𝑃[𝑋≥𝑘]≤𝐸[𝑋]/𝑘

Upvotes: 0

Views: 178

Answers (1)

user2554330
user2554330

Reputation: 44887

After the plot you've already drawn, add this code:

x <- sort(n01)
y <- mean(n01)/x
lines(x, y)

It's a very boring plot: over the range of n01, 1/x hardly changes at all:

It's a little more interesting if you change the range, but now the ECDF is crammed into a nearly vertical line:

x <- seq(2.6e7, 4e7, len=200)

plot(ccdf, xlim = range(x))

y <- mean(n01)/x
lines(x, y)

Upvotes: 0

Related Questions