Showing posts with label Inferential Statistics. Show all posts
Showing posts with label Inferential Statistics. Show all posts

Monday, June 8, 2020

Python for MBA's: Chisqaure test

Chi sqaure test using Google Colab



Independent test

Problem 1:

Perform the chi-square test for the following values
14,16,12,15,17

coding


import numpy as np
 
from scipy.stats import chisquare
 
chisquare([14,16,12,15,17])
 

output

Power_divergenceResult(statistic=1.0, 
pvalue=0.9097959895689501)
 

Thursday, June 4, 2020

R for MBA's- Chi sqaure test(Independent)


R for MBA's - Chi sqaure test (independent)


coding



x<-(1567,1233,1456,1678,1456,1111,1895)

> chisq.test(x)

Output


 Chi-squared test for given probabilities

data:  x

X-squared = 280.87, df = 6, p-value < 2.2e-16

Wednesday, May 27, 2020

Python for MBA's- One sample 't' test

T test

This is the most common hypothesis testing statistical test used in social science.
Today we will learn how to calculate One sample 't ' test using Python.

Problem:

Let us take Virat Kohli's  four  innings score in 2020 in New zealand in T 20 matches
They are
11,
38,
11,
45
His career average in T20 Internationals is 50.80
Now the hypothesis is

Virat Kohli's average in T20's in New Zealand 2020 series  significantly differs from career T 20 International average.

The Python code is given below.


import numpy as np
from scipy.stats import norm
from scipy import stats
Virat_t20I=(11,38,11,45)
# Perform t-test and print result
t_result=stats.ttest_1samp(Virat_t20I, 50.8)
print(t_result)

# Test significance
alpha= 0.05
if (t_result[1] < alpha):
    print("mean value of Virat_T20I differs from given value")
else:
  print("No significant difference found")
 

Solution:

Ttest_1sampResult(statistic=-2.7523096064356434, pvalue=0.07060545196814848)
No significant difference found
 
 
 

 

Wednesday, May 20, 2020

Python for MBA's- Correlation using Python


Method 1: Using Numpy Library

import numpy as np
advt=[5,10,15,20,25]
sales=[40,60,80,100,120]
a=np.corrcoef(advt,sales)
print(a)
Ans:
[[1. 1.]
 [1. 1.]]
 

Method 2: Using Scipy library

Problem2: Find the correlation between share volume of  Ajit 

industries and market volume of a sensex. The data is given below:

share volume : 25,35,28,22,34,32

Market volume: 35,55,42,36,45,41

Solution:

Coding:
 
import numpy as np
from scipy.stats import pearsonr
sharevolume=[25,35,28,22,34,32]
marketvolume=[35,55,42,36,45,41]
pearsonr(sharevolume,marketvolume)

Output

(0.8440172720849535, 0.034598339542112846)