Learn the fundamentals of the popular programming language JavaScript so that you can explore the realm of web development.

plot where y = x**2 for x over the interval 1 to 5, properly labelled

Create a histogram where the mean = 0, std. dev. = 1, n = 300, and there are sqrt(n) bins

Create a line plot of your choosing with an appropriate legend which displays the formula of the curve depicted.

The formula should be formatted using TeX syntax to create a professional presentation.

Create a histogram where the mean = 0, std. dev. = 1, n = 300, and there are sqrt(n) bins

Create a line plot of your choosing with an appropriate legend which displays the formula of the curve depicted.

The formula should be formatted using TeX syntax to create a professional presentation.

Do more with

EXPERT OFFICE^{®} is a registered trademark of EXPERTS EXCHANGE^{®}

- plot y=x**2 with TeX labels.

- plot a normal distribution within a range.

To plot y=x**2:

```
from numpy import linspace
import matplotlib.pyplot as mpl
x_vals = linspace(1, 5, 100)
y_vals = x_vals**2
mpl.plot(x_vals, y_vals)
mpl.xlabel("my x label")
mpl.ylabel("my y label")
mpl.legend(("$y=x^2$",))
mpl.show()
```

To plot a normal distribution you can create a function that picks points within the range you want (eg. 1 STD) and then plot it:

```
import matplotlib.pyplot as plt
import numpy
STANDARD_DEVIATION_VALUE = 1
DISTRIBUTION_CENTER = 0
TOTAL_POINTS = 300
NUMBER_OF_BINS = int(numpy.sqrt(TOTAL_POINTS))
def single_num(n):
# Repeats until a number within the scale is found.
while 1:
num = numpy.random.normal(loc=DISTRIBUTION_CENTER, scale=STANDARD_DEVIATION_VALUE)
if abs(DISTRIBUTION_CENTER-num) <= (STANDARD_DEVIATION_VALUE * n):
return num
# One standard deviation apart.
lst_of_nums = [single_num(n=1) for _ in range(TOTAL_POINTS)]
plt.hist(lst_of_nums, bins=NUMBER_OF_BINS)
plt.xlabel("value")
plt.ylabel("frequency")
plt.show()
```

(Note that I'm using "n" as "number of STDs")

On the other hand `x = linspace(1, 5, 1)` is an `ndarray`, and by using `x**2` you raise each element of `x` to the power of 2.

Also you should be using parenthesis since linspace is a function and needs a parenthesis to be called: `x = linspace(1, 5, 50)`

## Premium Content

You need an Expert Office subscription to comment.Start Free Trial