PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Thursday, October 6, 2022

[FIXED] How can I overlay 2 normal distribution curves on the same plot?

 October 06, 2022     distribution, r, statistics     No comments   

Issue

I'm brand new to R, and I'm facing a problem without much in- class resources. I need to do something that I'm sure is very simple. Can someone point me in the right direction? This is my task:

Let X denote the monthly return on Microsoft Stock and let Y denote the monthly return on Starbucks stock. Assume that X∼N(0.05,(0.10)2) and Y∼N(0.025,(0.05)2).

Using a grid of values between –0.25 and 0.35, plot the normal curves for X and Y. Make sure that both normal curves are on the same plot.

I've only been able to get a randomly generated normal distribution generated, but not both on the same plot, and not by specifying mean and st dev. Big thanks in advance.


Solution

use the functions lines or points, i.e.

s <- seq(-.25,.35,0.01)
plot(s, dnorm(s,mean1, sd1), type="l")
lines(s, dnorm(s,mean2, sd2), col="red")

also, check the function par (using ?par ) for plotting options, common options include labels (xlab/ylab), plotlimits (xlim/ylim), colors(col), etc...



Answered By - bpeter
Answer Checked By - Pedro (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home
View mobile version

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing