Friends don’t let you compare means without looking at the underlying distributiion by cxli233
Author
Marco Dalla Vecchia
Published
December 6, 2024
In [1]:
# import packagesimport numpy as npimport pandas as pdfrom matplotlib import pyplot as pltimport seaborn as sns# # Aestheticsplt.rcParams["font.family"] ="serif"# use Serif style as default fontsns.set_style('ticks')
In [2]:
# Fix random seed for creating random datanp.random.seed(69)# Create a group with random value from NORMAL distributiony1 = np.random.normal(1,1, 100)# Create another group with random value from LOGNORMAL distributiony2 = np.random.lognormal( mean=np.log(1**2/np.sqrt(1**2+1**2)), sigma=np.sqrt(np.log(1+(1**2/1**2))), size=100 )y = np.concatenate([y1,y2])# X labels for the plotx = np.concatenate([ np.repeat('Group 1', 100), np.repeat('Group 2', 100),])# Create full datasetdf = pd.DataFrame({'response': y, 'group': x})# Check that the means are actually very closeprint(np.mean(y1), np.mean(y2))