paint-brush
Método de Estratificación ukampi Análisis de Experimento ukatakiukata@nataliaogneva
33,155 ullart’awinaka
33,155 ullart’awinaka

Método de Estratificación ukampi Análisis de Experimento ukataki

ukata Natalia Ogneva8m2024/04/19
Read on Terminal Reader
Read this story w/o Javascript

Sinti jaya pachanakawa; Uñxatt’añataki

Muestreo estratificado ukaxa mä ch’amani técnica ukhamawa experimento eficiencia ukhamaraki sensibilidad métrica ukanaka análisis de datos ukanxa ch’amanchañataki. Uñch’ukirinakamar tantacht’asa ukat pesos específicos ukanakamp jaljasa, yant’äwinakarux sum apnaqasma, variancia ukar jisk’achasma, ukat resultadonakax confiabilidad ukar juk’amp ch’amanchasma.

Company Mentioned

Mention Thumbnail
featured image - Método de Estratificación ukampi Análisis de Experimento ukataki
Natalia Ogneva HackerNoon profile picture
0-item


Kuna yant’awis mä trade-off ukampiw rápidos resultados ukat sensibilidad métrica ukanakampi. Uka ajllit métrica ukax variancia tuqitx jach’akiwa, ukatx jaya pachaw suyt’añasa, ukhamat yant’awix chiqaparu uñjañataki. Mä thakhi amuyt’añäni, analisis ukar yanapt’añataki, yant’awinakapar ch’amanchañataki, jan sinti pacha chhaqhayasa, jan ukax sensibilidad métrica ukar chhaqhayasa.


Jan walt’awinaka Formulación

Mä machaq algoritmo de ranking ukar yant’añatakix mä experimento estándar lurañäni sasin amuyt’añäni, sesión largo ukax métrica primaria ukhamawa. Ukhamarus, amuyt’añäni, jiwasan ist’irinakax niya kimsa tamaruw jaljasipxaspa: 1 millón wayn tawaqunaka, 2 millón apnaqirinaka 18-45 maraninaka, ukat 3 millones apnaqirinaka 45 maranit jilïrinaka. Mä machaq algoritmo de ranking ukar jaysawix uka uñjir tamanakanx wali mayjt’aspawa. Aka jach’a mayjt’awix métrica ukan sensibilidad ukarux jisk’acharaki.


Mä arunxa, jaqinakax kimsa estratos ukar jaljatäspawa, ukax akham qhanañchatawa:


Sapa componente ukax mä distribución normal ukaniwa sañani. Ukatxa, jach’a métrica ukax población ukatakix mä distribución normal ukaniwa.

Ukaxa estratificación sata lurawimpiwa lurataraki

Jiwasax aleatoriamente taqi apnaqirinakaruw población ukan jaljapxta, mä diseño de experimento clásico ukanx jan jiwasan apnaqirinakasan mayjt’awinakapat amuyt’asa. Ukhamatwa, muestra ukax akham suyt’at valores ukat variancia ukampiw uñakipata.


Yaqha tuqitxa sapa estrato manqhanxa aleatoriamente jaljañawa, ukaxa estrato ukan pesaje ukarjamawa población general ukanxa.

Uka tuqinx suyt’at valores ukatx variancia ukax akhamawa.


Suyt’ata chimpuxa nayrïri ajlliwimpi kikiparakiwa. Ukampirus variancia ukax juk’akiw, ukax juk’amp jach’a sensibilidad métrica ukar garantiza.

Jichhax Neyman chachan lurawipat amuyt’añäni . Jupanakax sapa strat manqhanx apnaqirinakarux aleatoriamente pesos específicos ukanakamp jaljañ amtapxi.

Ukhamarusa, suyt’ata valor ukhamaraki variancia ukaxa aka tuqinxa akhamawa.

Suyt’ata chimpuxa nayrïri pachanxa asintóticamente suyt’ata chimpumpiwa kikipa. Ukampirus, variancia ukax juk’amp jisk’akiwa.

Yant’awinaka Empírica uka tuqita

Jiwasax teóricamente uka thakhix wali askiwa sasaw uñacht’ayawaytanxa. Muestras simulación ukat método de estratificación empíricamente yant’añäni.

Kimsa tuqit amuytʼañäni:

  • taqi strats ukanakax mä kipka medios ukat variancias ukanakampi, .
  • taqi strats ukanakaxa kunaymana medios ukanakampi ukhamaraki variancias iguales ukanakampi, .
  • taqi strats ukanakax mä kipka medios ukat variancias ukanakampi.

Kimsa lurawixa taqi chiqanwa apnaqatarakini, ukatxa histograma ukatxa cuadro de cuadros ukanakampi chikachasiñatakixa uñacht’ayañäni.

Código wakicht’aña

Nayraqatxa, mä clase Python ukan lurañäni, ukax jiwasan población general ukar uñtasitawa, ukax kimsa strat ukan luratawa.

 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]


Ukatxa, kimsa muestreo thakhinak lurañatakix funciones ukanakamp yapxatañäni, ukax teórico uksan qhanañchatawa.

 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


Ukhamaraki, chiqa empírico ukatakixa, sapa kutiwa mä función ukaxa simulación proceso de experimento ukatakixa wakisi.

 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


Simulación ukax mä resultado ukhamawa

Jiwasatixa población general uñakipañänixa, kawkhantixa taqpacha estratos ukanakaxa pachpa valores ukhamaraki variancias ukanakampiwa, kimsa lurawimpixa juk ampi jani ukaxa juk ampi kikipakiw suyt ataraki.

Kunayman medios ukat igual variancias ukanakax juk’amp kusiskañ askinak jikxatapxi. Estratificación apnaqañax variancia ukarux wali jisk’acharaki.

Ukasti medios iguales ukatxa variancias ukanakampixa, Neyman ukan lurawipanxa mä variancia jisk’achawi uñjtanxa.

Tukuyawi

Jichhax, método de estratificación ukax varianza métrica ukar jisk’achañatakiw apnaqasispa ukat experimento ukar ch’amanchañataki, audiencia ukar cluster ukat técnicamente sapa clúster manqhan aleatoriamente pesos específicos ukanakamp jaljañataki!