Python统计代写|Bonus Assignment: Simulating experiments


Consider the following two-sample data from Real Statistics:

The results for this dataset are:

Recall from Lesson 08 that the two-sample t statistic is defined as:

where sp is the pooled standard deviation:

In order to complete the tasks below, you will need the following packages:

Task 1: Write a function called t_two_sample which (1) has two input arguments: yA and yB, and which (2) calculates the t-value for a two-sample test.

Task 2: Use your t_two_sample function to verify the t value reported for the dataset above ( t=2.177 ).

Task 3: Use scipy.stats.t.sf to verify the p value reported for the dataset above ( p=0.022 ).

Task 4: Simulate at least 1000 two-sample experiments to numerically verify the reported p value ( p=0.022 ).