This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import math | |
x = 0 #it would be 0 for 0 heads, 1 for 1 heads, 2 for 2 heads, 3 for 3 heads | |
n = 3 #number of trials expected to run | |
prob = 0.5 #probability of success or failure | |
def combination(n,r): | |
fac = math.factorial | |
return fac(n) / fac(r) / fac(n-r) | |
pmf_probability = combination(n,x) * (prob**x) * ( (1-prob)**(n-x) ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
##import required modules | |
import matplotlib.pyplot as plt | |
import numpy as np | |
import scipy.stats as stats | |
import math | |
from matplotlib.ticker import StrMethodFormatter | |
###Python-Graph-1 in article titled Jump from discrete to a continuous distribution | |
##Create the grid | |
fig, axes = plt.subplots(2, 2, figsize=(10,8)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
##import required modules | |
import numpy as np | |
import scipy.stats as stats | |
import math | |
x = round(stats.norm.ppf(0.975),2) #x gives us 1.96 instead of 2.0 | |
b = stats.norm.cdf(x) | |
a = stats.norm.cdf(-x) | |
y = round(b-a, 6) | |
print(y) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
##import required modules | |
import numpy as np | |
import scipy.stats as stats | |
import math | |
sample_size = 40 #known from the sample collected by the manager | |
sample_success = 25 #known from the sample collected by the manager | |
proportion = sample_success/sample_size #sample proportion who rated more 6 or more | |
point_estmate = proportion #similar to proportion of the sample | |
standard_error = np.sqrt((proportion * (1-proportion))/sample_size) #formula is slightly different relative to population mean estimation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
##import required modules | |
import numpy as np | |
import scipy.stats as stats | |
import math | |
sample_size = 30 #known from the sample collected by the manager | |
population_size = 1184 #known in this specific case therefore required for fpc calc | |
sample_std = 4.46 #standard deviation of all sample means | |
point_estmate = 55.45 #as we take more and more samples the sample mean would converge to population mean |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#install.packages("readr") | |
library(readr) | |
data <- read.csv("https://raw.githubusercontent.com/arimitramaiti/datasets/master/articles/adjacency_matrix_mumbailocal.csv", header = TRUE, sep = ",") | |
mat <- as.matrix(data[, -1L]) | |
rownames(mat) <- unlist(data[,1L]) | |
#install.packages("igraph") | |
library("igraph") | |
#Create graph object using igraph library |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
##Import required modules | |
import numpy as np | |
import pandas as pd | |
import matplotlib.pyplot as plt | |
import seaborn as sns | |
%matplotlib inline | |
import scipy.stats as stats | |
import math | |
##Read the centrality scores generated from empirical network of mumbai local rail |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
##Import required modules | |
import numpy as np | |
import pandas as pd | |
import matplotlib.pyplot as plt | |
import seaborn as sns | |
%matplotlib inline | |
import scipy.stats as stats | |
import math | |
##Read the centrality scores generated from empirical network of mumbai local rail |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#install.packages("igraph") | |
library("igraph") | |
#Create empty list | |
degree_list = list() | |
closeness_list = list() | |
betweenness_list = list() | |
eigen_list = list() | |
for (i in 1:100) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
##Import required modules | |
import numpy as np | |
import pandas as pd | |
import matplotlib.pyplot as plt | |
import seaborn as sns | |
%matplotlib inline | |
import scipy.stats as stats | |
import math | |
##Read the centrality scores generated from empirical network of mumbai local rail |
OlderNewer