Question: Create a markdown cell with a level 1 header that reads: DSCI 3 0 3 - Homework 0 5 . Add your name below

Create a markdown cell with a level 1 header that reads: "DSCI 303- Homework 05". Add your name below that as a level 3
header
Import the following packages: numpy, math, and matplotlib.pyplot. No other packages should be used in this project.
Problem 1: Sample Mean and Variance
In this problem, you will be asked to use NumPy to calculate sample mean and variance of a data set in two ways:
1. First using numpy to perform the calculations indicated by the formulas for these values, and
2. Then using built-in NumPy functions for the mean and variance.
We start with a discussion of the necessary formulas. Given a collection of numerical observations 1,2,...,, the
sample mean and sample variance 2 of the observations are given by the following formulas:
Sample mean: =1
=1=1
(1+2++)
Sample variance: 2=1
1()2
=1=1
1[(1)2+(2)2++()2]
Create a code cell to perform the following steps:
1. Create an array x containing the following integers: 10,16,26,12,17,22,14,12,21,16
2. Store the length of this array in a variable n.
3. Calculate the sample mean, storing the result in mean. You may use np.sum() in your calculation.
4. Calculate an array named diff that stores the differences between each value in x and the mean. That is to
that that diff should contain values () for each=1,...,.
5. Use diff, n, and np.sum() to find the sample variance. Store the result in a variable named var.
6. Print your results in the format shown below. Make sure that the numerical outputs are aligned with each other
on the left.
Sample Mean: xxxxx
Sample Variance: xxxxx
Your code in Problem 1 should not include any loops.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!