lab08.pdf - lab091 CS 237 Lab Nine Displaying Multivariate Data Due date PDF ﬁle due Thursday November 15st 11:59PM(10 oﬀ if up to 24 hours late in

lab08.pdf - lab091 CS 237 Lab Nine Displaying Multivariate...

• Lab Report
• 32

This preview shows page 1 - 4 out of 32 pages.

6/25/2019 lab091 localhost:8889/nbconvert/html/Desktop/CS237/lab091.ipynb?download=false 1/32 CS 237 Lab Nine: Displaying Multivariate Data Due date: PDF file due Thursday November 15st @ 11:59PM (10% off if up to 24 hours late) in GradeScope General Instructions Please complete this notebook by filling in solutions where indicated. Be sure to "Run All" from the Cell menu before submitting. You may use ordinary ASCII text to write your solutions, or (preferably) Latex. A nice introduction to Latex in Jupyter notebooks may be found here: - blog.udacity.com/posts/2016/10/latex-primer/ () As with previous homeworks, just upload a PDF file of this notebook. Instructions for converting to PDF may be found on the class web page right under the link for homework 1.

Subscribe to view the full document.

6/25/2019 lab091 localhost:8889/nbconvert/html/Desktop/CS237/lab091.ipynb?download=false 2/32 In [3]: # General useful imports import numpy as np from numpy import arange,linspace, mean, var, std, sin, cos from numpy.random import random, randint, uniform, choice, binomial, geometric, poisson import math from mpl_toolkits.mplot3d import Axes3D import matplotlib.pyplot as plt from matplotlib import cm import matplotlib.mlab as mlab from matplotlib.ticker import LinearLocator, FormatStrFormatter from collections import Counter #import pandas as pd % matplotlib inline # Basic Numpy statistical functions X = [ 1 , 2 , 3 ] # mean of a list mean(X) # might need to use np.mean, np.var, and np.std # population variance var(X) # sample variance ddof = delta degrees of freedom, df = len(X) - ddof var(X,ddof =1 ) # population standard deviation std(X) # sample standard deviation std(X,ddof =1 ) # Scipy statistical functions # Scipy Stats Library Functions, see: # from scipy.stats import norm,t,binom,geom,expon,poisson,uniform,bernoulli # Uniform over interval [0..1) # generate n random variates n =1000 uniform . rvs(size = n) # Bernoulli # generate n random variates p =0.5 bernoulli . rvs(p,size = n) # Binomial: X ~ B(n,p) # Example parameters k = 4 n = 10 p = 0.5 # Probability Mass Function: P(X = x) binom . pmf(k, n, p) # Cumulative Distribution Function: P(X <= x) binom . cdf(k, n, p) # Generate n random variates binom . rvs(n, p, size = n) # Geometric Distribution X ~ G(p) # Probability Mass Function: P(X = k) geom . pmf(k,p) # Cumulative Distribution Function: P(X <= k) geom . cdf(k,p) # Generate n random variates geom . rvs(p,size = n) # my own version of the previous which only generates rvs up to # a limit -- this is not the same as the original distribution but # useful for displaying data in which you want to fix the size of the display def geom_rvs (p =0.5 ,size =1 ,limit =20 ): if size ==1 : x = geom . rvs(p) while x >= limit: x = geom . rvs(p) return x else :
6/25/2019 lab091 localhost:8889/nbconvert/html/Desktop/CS237/lab091.ipynb?download=false 3/32 lst = [ 0 ] * size for k in range (size): x = geom . rvs(p) while x >= limit: x = geom . rvs(p) lst[k] = x return lst # Poisson Distribution X ~ Poisson(lam) lam = 2 k =3 # P(X = k) poisson . pmf(k,lam) # P(X <= k) poisson . cdf(k,lam) # P(X > k) poisson . sf(k,lam) # Generate n random variates poisson . rvs(lam,size = n) # Exponential # Example parameters lam = 2 # rate parameter

Subscribe to view the full document.

• Summer '19
• Normal Distribution, Probability theory, probability density function, Cumulative distribution function, matplotlib

What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern

Ask Expert Tutors You can ask 0 bonus questions You can ask 0 questions (0 expire soon) You can ask 0 questions (will expire )
Answers in as fast as 15 minutes