Answers for "Set up and run a two-sample independent t-test"

1

Set up and run a two-sample independent t-test

# Import the libraries
import numpy as np
from scipy import stats
np.random.seed(42)

# Generate the random variables with the specified mean, std, and sample size
rvs1 = stats.norm.rvs(loc=5, scale=10,size=500)
rvs2 = stats.norm.rvs(loc=5, scale=20, size=500)

# Calculate the t statistic for these two sample populations
stats.ttest_ind(rvs1, rvs2)
Posted by: Guest on September-07-2021

Python Answers by Framework

Browse Popular Code Answers by Language