Wk2-3-demo
COMP2420/COMP6420 – Introduction to Data Management, Analysis and Security
Lecture 6 – Demo Example
Copyright By PowCoder代写 加微信 powcoder
Author in R – – 10 Mar 2019
Python Conversion – [ ]:
import pandas as pd
import numpy as np
import statistics as stats
from scipy import stats as spystats
import matplotlib as plt
import statsmodels as sm
%matplotlib inline
Based on the information in the lecture, we should now be able to talk about a testing such as chisquare. While we will cover Hypothesis Testing using T-tests in Lab03, we will talk about the chi square test now.
iPhone Information¶
We will be using this fake datasets of phone sales to show how to perform a Chisquare test on data.
For the sake of this exercise, we define a chi square test:
The chi square test tests the null hypothesis that the categorical data has the given frequencies
Therefore, you are comparing if there is difference between an observation and an expected frequency.
# Data sets
phones = {‘iPhone 6’: 30, ‘iPhone 6 Plus’: 36, ‘iPhone 7 Plus’: 25, ‘iPhone 8’: 22}
Seat Belt Usage¶
Another fake dataset, this time for showing another varient of the chi square test. The contingency test for the chi square is defined:
chi square test of independence of variables in a contingency table
Therefore, you are testing if there is there is relationship between two or more variables.
belt_df = pd.DataFrame(np.array([[56,8], [2,16]]), columns=[‘Child Buckled’, ‘Child Unbuckled’])
belt_df.rename(index={0:”Parent Buckled”, 1:”Parent Unbuckled”}, inplace=True)
程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com