I am plotting 2 normal distribution in Python. if anyone could provide an R version to demonstrate and explain, that would be grateful.

f, a = plt.subplots(figsize=(3,3))
x1 = np.random.normal(loc=3.0, size=1000)
y1 = np.random.normal(loc=2.0, size=1000)
a.scatter(x1,y1,color='red', marker='+',s=15, alpha=.05)

x1, y1 are 2 independent(thanks to @mlofton) separate random variables with different normal distributions.

plotting x1, y1, produces this figure

enter image description here

the question is, is it reasonable to consider the red circle as the geometric representation of a joint probability distribution?

if yes, what a math formula is?

  • 1
    $\begingroup$ yeah but the covariance matrix has zero on the non-diagonals ( since they are independently drawn. I think. I'm not familiar with that code ) so you are just plotting 2 independent normals whose joint distribution is a product of each of the marginals. if you use covariance matrices with values on the diagonals, it will become more ellipitic shaped. In R, it's easy. Don't know that language you are using. $\endgroup$ – mlofton May 9 '19 at 3:01
  • $\begingroup$ @mlofton thanks for your comments! this is in Python. an R version to demonstrate and explain this would be grateful. $\endgroup$ – shi95 May 9 '19 at 3:10
  • $\begingroup$ Perhaps see plts and R code in this Q & A. $\endgroup$ – BruceET May 9 '19 at 4:13
  • $\begingroup$ @shi95: I'm pretty busy so can you check out the link that Brucet mentioned. Generating bvariate normals in R is pretty straightforward so, if you want to do that, check out that R code and then do "generating bivariate normal random variables in R". That should bring up relevant code. $\endgroup$ – mlofton May 10 '19 at 2:05
  • $\begingroup$ Here's a link . blog.revolutionanalytics.com/2016/08/… $\endgroup$ – mlofton May 10 '19 at 2:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.