Answered step by step
Verified Expert Solution
Link Copied!

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 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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Management System MCQs Multiple Choice Questions And Answers

Authors: Arshad Iqbal

1st Edition

1073328554, 978-1073328550

More Books

Students also viewed these Databases questions

Question

Describe what configuration management encompasses.

Answered: 1 week ago