Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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 header that reads: "DSCI Homework Add your name below that as a level
header
Import the following packages: numpy, math, and matplotlib.pyplot. No other packages should be used in this project.
Problem : 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:
First using numpy to perform the calculations indicated by the formulas for these values, and
Then using builtin NumPy functions for the mean and variance.
We start with a discussion of the necessary formulas. Given a collection of numerical observations the
sample mean and sample variance of the observations are given by the following formulas:
Sample mean:
Sample variance:
Create a code cell to perform the following steps:
Create an array x containing the following integers:
Store the length of this array in a variable n
Calculate the sample mean, storing the result in mean. You may use npsum in your calculation.
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
Use diff, n and npsum to find the sample variance. Store the result in a variable named var.
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 should not include any loops.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started