Jaribio lolote linahusisha ubadilishanaji kati ya matokeo ya haraka na unyeti wa kipimo. Ikiwa kipimo kilichochaguliwa ni pana kulingana na tofauti, ni lazima tusubiri kwa muda mrefu ili kuhakikisha kuwa matokeo ya jaribio ni sahihi. Hebu tuzingatie njia moja ya kuwasaidia wachanganuzi kuimarisha majaribio yao bila kupoteza muda mwingi au unyeti wa vipimo.
Tuseme tutafanya jaribio la kawaida ili kujaribu kanuni mpya ya nafasi, na urefu wa kipindi kama kipimo msingi. Zaidi ya hayo, zingatia kuwa hadhira yetu inaweza kugawanywa katika vikundi vitatu: vijana milioni 1, watumiaji milioni 2 wenye umri wa miaka 18-45, na watumiaji milioni 3 wenye umri wa miaka 45 na zaidi. Majibu kwa kanuni mpya ya nafasi yatatofautiana kwa kiasi kikubwa kati ya vikundi hivi vya hadhira. Tofauti hii pana hupunguza unyeti wa kipimo.
Kwa maneno mengine, idadi ya watu inaweza kugawanywa katika tabaka tatu, kama ilivyoelezwa katika zifuatazo:
Wacha tuseme kwamba kila sehemu ina usambazaji wa kawaida. Kisha, kipimo kikuu cha idadi ya watu pia kina usambazaji wa kawaida.
Tunagawanya watumiaji wote kwa nasibu kutoka kwa idadi ya watu katika muundo wa kawaida wa majaribio bila kuzingatia tofauti kati ya watumiaji wetu. Kwa hivyo, tunazingatia sampuli na thamani ifuatayo inayotarajiwa na tofauti.
Njia nyingine ni kugawanya kwa nasibu ndani ya kila tabaka kulingana na uzito wa tabaka katika idadi ya watu kwa ujumla.
Katika kesi hii, thamani inayotarajiwa na tofauti ni zifuatazo.
Thamani inayotarajiwa ni sawa na katika uteuzi wa kwanza. Walakini, tofauti ni ndogo, ambayo inahakikisha unyeti wa juu wa metri.
Sasa, hebu tuzingatie mbinu ya Neyman . Wanapendekeza kugawa watumiaji nasibu ndani ya kila safu na uzani maalum.
Kwa hivyo, thamani inayotarajiwa na tofauti ni sawa na zifuatazo katika kesi hii.
Thamani inayotarajiwa ni sawa na thamani inayotarajiwa katika kesi ya kwanza bila dalili. Walakini, tofauti ni kidogo sana.
Tumethibitisha ufanisi wa njia hii kinadharia. Wacha tuige sampuli na tujaribu mbinu ya kuweka tabaka kwa nguvu.
Wacha tuchunguze kesi tatu:
Tutatumia njia zote tatu katika visa vyote na kupanga histogram na sanduku la sanduku ili kuzilinganisha.
Kwanza, wacha tuunde darasa katika Python ambalo linaiga idadi yetu ya jumla inayojumuisha tabaka tatu.
class GeneralPopulation: def __init__(self, means: [float], stds: [float], sizes: [int], random_state: int = 15 ): """ Initializes our General Population and saves the given distributions :param means: List of expectations for normal distributions :param stds: List of standard deviations for normal distributions :param sizes: How many objects will be in each strata :param random_state: Parameter fixing randomness. Needed so that when conducting experiment repeatedly with the same input parameters, the results remained the same """ self.strats = [st.norm(mean, std) for mean, std in zip(means, stds)] self._sample(sizes) self.random_state = random_state def _sample(self, sizes): """Creates a general population sample as a mixture of strata :param sizes: List with sample sizes of the corresponding normal distributions """ self.strats_samples = [rv.rvs(size) for rv, size in zip(self.strats, sizes)] self.general_samples = np.hstack(self.strats_samples) self.N = self.general_samples.shape[0] # number of strata self.count_strats = len(sizes) # ratios for every strata in GP self.ws = [size/self.N for size in sizes] # ME and Std for GP self.m = np.mean(self.general_samples) self.sigma = np.std(self.general_samples) # ME and std for all strata self.ms = [np.mean(strat_sample) for strat_sample in self.strats_samples] self.sigmas = [np.std(strat_sample) for strat_sample in self.strats_samples]
Kisha, hebu tuongeze utendakazi kwa mbinu tatu za sampuli zilizoelezwa katika sehemu ya kinadharia.
def random_subsampling(self, size): """Creates a random subset of the entire population :param sizes: subsample size """ rc = np.random.choice(self.general_samples, size=size) return rc def proportional_subsampling(self, size): """Creates a subsample with the number of elements, proportional shares of strata :param sizes: subsample size """ self.strats_size_proport = [int(np.floor(size*w)) for w in self.ws] rc = [] for k in range(len(self.strats_size_proport)): rc.append(np.random.choice(self.strats_samples[k], size=self.strats_size_proport[k])) return rc def optimal_subsampling(self, size): """Creates a subsample with the optimal number of elements relative to strata :param sizes: subsample size """ sum_denom = 0 for k in range(self.count_strats): sum_denom += self.ws[k] * self.sigmas[k] self.strats_size_optimal = [int(np.floor((size*w*sigma)/sum_denom)) for w, sigma in zip(self.ws, self.sigmas)] if 0 in self.strats_size_optimal: raise ValueError('Strats size is 0, please change variance of smallest strat!') rc = [] for k in range(len(self.strats_size_optimal)): rc.append(np.random.choice(self.strats_samples[k], size=self.strats_size_optimal[k])) return rc
Pia, kwa sehemu ya majaribio, tunahitaji kila mara chaguo la kukokotoa ili kuiga mchakato wa majaribio.
def run_experiments(self, n_sub, subsampling_method, n_experiments=1000): """Conducts a series of experiments and saves the results :param n_sub: size of sample :param subsampling_method: method for creating a subsample :param n_experiments: number of experiment starts """ means_s = [] if(len(self.general_samples)<100): n_sub = 20 if(subsampling_method == 'random_subsampling'): for n in range(n_experiments): rc = self.random_subsampling(n_sub) mean = rc.sum()/len(rc) means_s.append(mean) else: for n in range(n_experiments): if(subsampling_method == 'proportional_subsampling'): rc = self.proportional_subsampling(n_sub) elif(subsampling_method == 'optimal_subsampling'): rc = self.optimal_subsampling(n_sub) strats_mean = [] for k in range(len(rc)): strats_mean.append(sum(rc[k])/len(rc[k])) # Mean for a mixture means_s.append(sum([w_k*mean_k for w_k, mean_k in zip(self.ws, strats_mean)])) return means_s
Tukiangalia idadi ya watu kwa ujumla, ambapo tabaka zetu zote zina maadili na tofauti zinazofanana, matokeo ya mbinu zote tatu yanatarajiwa kuwa zaidi au chini ya usawa.
Njia tofauti na tofauti sawa zilipata matokeo ya kusisimua zaidi. Kutumia utabaka hupunguza kwa kiasi kikubwa tofauti.
Katika hali zenye njia sawa na tofauti tofauti, tunaona kupunguzwa kwa tofauti katika mbinu ya Neyman.
Sasa, unaweza kutumia mbinu ya kuweka tabaka ili kupunguza tofauti za vipimo na kuongeza jaribio ikiwa utakusanya hadhira yako na kuigawanya kitaalam nasibu ndani ya kila kundi kwa uzani mahususi!