def _update_parameters(self): """Update mean sd etc after we have updated our samples """ self.n = len(self.members) self.mean = self.orig_mean = StatTool.calc_mean(self.members) self.sd = self.orig_sd = StatTool.calc_sd(self.members, self.is_population) print("Got %d samples, mean: %.3f, sd: %.3f" % (self.n, self.mean, self.sd))
def _fix_samples(self): """Decide if the two samples are dependent and we should do something about it""" samp_dependent = not self.samp0.is_population and not self.samp1.is_population if samp_dependent and self.samp0.members and self.samp1.members: members = [self.samp1.members[i] - self.samp0.members[i] for i in range(len(self.samp1.members))] self.samp0.mean = 0.0 self.samp0.sd = None self.samp0.notes = "mean and sd have been reset" self.samp1.mean = StatTool.calc_mean(members) self.samp1.sd = StatTool.calc_sd(members, self.samp1.is_population) self.samp1.notes = "mean and sd are difference from sample-0" elif samp_dependent and self.samp0.orig_sd is not None and self.samp1.orig_sd is not None: self.samp1.sd = self.standard_deviation_difference() self.samp1.notes = "sd is difference from sample-0"