Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8539741
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T11:26:19+00:00 2026-06-11T11:26:19+00:00

X ~ N(mu, 3*sigma^2) Y ~ N(mu,sigma^2) I am trying to graphically demonstrate that

  • 0

X ~ N(mu, 3*sigma^2)

Y ~ N(mu,sigma^2)

I am trying to graphically demonstrate that P[ |X-mu| < sigma ] < P[ |Y-mu| < sigma ] (i.e., the area under the blue curve is less than the area under the red curve between 0 and sigma)

I have created the pdfs of |X-mu| and |Y-mu| with the following code where I let mu=0 and sigma=1:

x<-seq(-10,10,length=10000000)

y1<-rnorm(x,mean=0,sd=sqrt(3))
y2<-rnorm(x,mean=0,sd=1)

absy1<-abs(y1-mean(y1))
absy2<-abs(y2-mean(y2))

plot(density(absy2), type="l", axes=FALSE, xlab = "", ylab = "", main="", col="red")
lines(density(absy1), col="blue")

abline(v=1,lty=2,col="black")

text(3.5,0.18,expression(abs(N(mu,3 * sigma^2)-mu)), col="blue")
text(1.5,0.48,expression(abs(N(mu,sigma^2)-mu)), col="red")
axis(1,at=0,labels=0, line=-1)
axis(1,at=1,labels=expression(sigma), line=-1)

Here is a link to the image produced by the above code that I’m trying to use:

https://lh3.googleusercontent.com/-wYtqZpKfkQs/UFXzvAdB1WI/AAAAAAAAACU/W9bXfk-ghew/s371-p-k/HW2problem2graph-iv.jpg

I want to shade the region under each curve between 0 and sigma.

To shade other, normal distribution curves, I’ve been using something like the line below, but I can’t use it with this problem (or I don’t know how).

polygon(c(0,xred,10),c(0,yred,0),col="mistyrose", border=NA)

Your help is much appreciated! Also, if there is a better way to draw the curves, please advise! (It’s my second day learning R, so please try to be very clear!) Thanks.

SOLUTION – thanks to @DWin

x<-seq(-10,10,length=10000000)

y1<-rnorm(x,mean=0,sd=sqrt(3))
y2<-rnorm(x,mean=0,sd=1)

absy1<-abs(y1-mean(y1))
absy2<-abs(y2-mean(y2))

plot(den2 <-density(absy2), type="l", axes=FALSE, xlab = "", ylab = "", main="", col="red")
with(den2, polygon(x=c(0, x[x < 1], rev(x[x<1]), 0), y=c(0, 0*x[x < 1], rev(y[x<1]), 0), col="mistyrose", border=NA))

lines(den1 <-density(absy1), col="blue")
with(den1, polygon(x=c(0, x[x < 1], rev(x[x<1]), 0), y=c(0, 0*x[x < 1], rev(y[x<1]), 0), col="aliceblue", border=NA))

abline(v=1,lty=2,col="black")

text(3.5,0.18,expression(abs(N(mu,3 * sigma^2)-mu)), col="blue")
text(1.75,0.48,expression(abs(N(mu,sigma^2)-mu)), col="red")
axis(1,at=0,labels=0, line=-1)
axis(1,at=1,labels=expression(sigma), line=-1)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T11:26:21+00:00Added an answer on June 11, 2026 at 11:26 am

    The density function produces a side-effect of plotting a graph but it also return a list with named ‘x’ and ‘y’ components, so you need to save that as a named object (which I am naming ‘den1’) and work with those components. Since you haves some “slop” in your density diagram you might want to look at the ‘logspline’ package which ISTR has a density function that accepts constraints.

    So do this instead as your initial plotting strategy::

    plot(den2 <-density(absy2), type="l", axes=FALSE, xlab = "", ylab = "", main="", col="red")
    lines(den1 <-density(absy1), col="blue")
    

    And then add the colored polygon (‘sigma’ being 1 in this case):

    with( den1, polygon(x=c(0, x[x < 1],   rev(x[x<1]), 0), 
                        y=c(0, 0*x[x < 1], rev(y[x<1]), 0), col="red") )
    

    Broken down into 4 components you are outlining the region with a starting point [0,0] then drawing along the x-axis to [sigma,0] then a vertical line to [sigma, density(sigma)], then going backwards along the density curve and closing back at [0,0].

    enter image description here

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to make a certain tone curve which is known as Sigma. Unfortunately,
I have some code dynamically created by Sigma, which looks like this: <div id=myGrid1_headDiv
I'm trying to get two-column typesetting working, with a list of items. However, that
I am trying to write a function that returns a one dimentional gauss filter.
I have been trying to build SVM classifier but having trouble with predict .
I am trying to get http://www.emacswiki.org/emacs/PrettyGreek working for emacs 21.3.1 on Windows. I have
I am trying to output a sigma character (σ) in a label in a
I'm trying to get a recipe working that I found online for doing expectation
I'm trying to write a program that does the following: Given two intervals A
Here's the sample C code that I am trying to accelerate using SSE, the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.