1

I have an array of random integers for which I have calculated the mean and std, the standard deviation. Next I have an array of random numbers within the normal distribution of this (mean, std).

I want to plot now a scatter plot of the normal distribution array using matplotlib. Can you please help?

Code:

random_array_a = np.random.randint(2,15,size=75)  #random array from [2,15) 
mean = np.mean(random_array_a)     
std = np.std(random_array_a)    
sample_norm_distrib = np.random.normal(mean,std,75)

The scatter plot needs x and y axis...but what should it be?

Mr. T
  • 11,960
  • 10
  • 32
  • 54
Py_Student
  • 163
  • 1
  • 12
  • Difficult to know, what you ask for, when you don't know, what it is. Maybe your assignment is about a [Normal Probability Plot](https://www.itl.nist.gov/div898/handbook/eda/section3/normprpl.htm)? – Mr. T Oct 28 '18 at 07:56

2 Answers2

1

I think what you may want is a histogram of the normal distribution:

import matplotlib.pyplot as plt
%matplotlib inline

plt.hist(sample_norm_distrib)

enter image description here

Franco Piccolo
  • 6,845
  • 8
  • 34
  • 52
  • thanks for your comment. I have to post a scatter plot though for my assignment. – Py_Student Oct 28 '18 at 07:37
  • Oh, I thought the histogram would make more sense than the scatter, the question is what do you want on the scatter, the code for scatterplot is plt.scatter(x,y) – Franco Piccolo Oct 28 '18 at 07:56
0

The closest thing you can do to visualise your distribution of 1D output is doing scatter where your x & y are the same. this way you can see more accumulation of data in the high probability areas. For example:

import numpy as np
import matplotlib.pyplot as plt

mean = 0    
std = 1 
sample_norm_distrib = np.random.normal(mean,std,7500)

plt.figure()
plt.scatter(sample_norm_distrib,sample_norm_distrib)

enter image description here

YoniChechik
  • 1,397
  • 16
  • 25