AllenDowney / ThinkStats2

Text and supporting code for Think Stats, 2nd Edition
http://allendowney.github.io/ThinkStats2/
GNU General Public License v3.0
4.02k stars 11.28k forks source link

Exercise 9.2: Make null hypothesis model for resampling #123

Closed kavyajeetbora closed 2 years ago

kavyajeetbora commented 5 years ago

What is the difference in randomly choosing the data from pooled data And Reshuffling the pooled data and then dividing it into two groups ??

In the code provided as solution the pooled data is again randomly chosen, which makes the model similar to the previous one we did for the chapter 9.

resampling model:

def RunModel(self):

        group1 = np.random.choice(**self.pool**, self.n, replace=True)
        group2 = np.random.choice(**self.pool**, self.m, replace=True)
        return group1, group2

pooled null hypothesis model:

def RunModel(self):
  np.random.shuffle(self.pool)
  data = self.pool[:self.n], self.pool[self.n:]
return data

Can somebody please clarify ?