Vaongorori vanowanzosangana nevanoburitsa mudhata panguva yebasa ravo, senge panguva yeAB-yekuongorora bvunzo, kugadzira mamodheru ekufungidzira, kana mafambiro ekutevera. Sarudzo dzinowanzoenderana nemuenzaniso zvinoreva, izvo zvinonyanya kunzwisiswa kune vekunze uye zvinogona kushandura zvakanyanya kukosha. Saka, zvakakosha kubata vekunze kuti vaite sarudzo chaiyo.
Ngatitarisei nzira dzinoverengeka dziri nyore uye dzinokurumidza dzekushanda nemaitiro asina kujairika.
Fungidzira kuti iwe unofanirwa kuita ongororo yekuyedza uchishandisa avhareji yekuodha kukosha seyekutanga metric. Ngatitii metric yedu kazhinji ine yakajairika kugovera. Zvakare, isu tinoziva kuti kugovera metric muboka rekuyedza kwakasiyana neiyo mukutonga. Mune mamwe mazwi, zvinoreva kugoverwa mukutonga ndeye 10, uye mumuedzo ndeye 12. Kutsauka kwemaitiro mumapoka ose ari matatu.
Nekudaro, ese masamples ane ekunze anotsvedza nzira yekuenzanisira uye chiyero chekutsauka.
import numpy as np N = 1000 mean_1 = 10 std_1 = 3 mean_2 = 12 std_2 = 3 x1 = np.concatenate((np.random.normal(mean_1, std_1, N), 10 * np.random.random_sample(50) + 20)) x2 = np.concatenate((np.random.normal(mean_2, std_2, N), 4 * np.random.random_sample(50) + 1))
NB kuti kufunga metric kunogona kuve nekubuda kubva kumativi ese. Kana metric yako yaingove nekunze kubva kune rimwe divi, nzira dzinogona kushandurwa zviri nyore kune icho chinangwa.
Nzira iri nyore ndeyekucheka zvese zvinoonekwa pamberi pe5% percentile uye mushure me95% percentile . Muchiitiko ichi, takarasikirwa ne10% yeruzivo senge con. Nekudaro, izvo zvinogovewa zvinotaridzika zvakanyanya kuumbwa, uye nguva dzemuenzaniso dziri pedyo nenguva dzekugovera.
import numpy as np x1_5pct = np.percentile(x1, 5) x1_95pct = np.percentile(x1, 95) x1_cutted = [i for i in x1 if i > x1_5pct and i < x1_95pct] x2_5pct = np.percentile(x2, 5) x2_95pct = np.percentile(x2, 95) x2_cutted = [i for i in x2 if i > x2_5pct and i < x2_95pct]
Imwe nzira ndeyekubvisa zvakaonekwa kunze kweiyo yakatarwa . Iyo yakaderera bhendi yakaenzana ne25% percentile minus one-half of interquartile range, uye bhendi repamusoro rakaenzana ne75% percentile plus one-half. Pano, isu ticharasikirwa chete ne0.7% yeruzivo. Kugoverwa kunotaridzika kwakaumbwa kupfuura kwekutanga. Nguva dzemuenzaniso dzakatonyanya kuenzana nenguva dzekugovera.
import numpy as np low_band_1 = np.percentile(x1, 25) - 1.5 * np.std(x1) high_band_1 = np.percentile(x1, 75) + 1.5 * np.std(x1) x1_cutted = [i for i in x1 if i > low_band_1 and i < high_band_1] low_band_2 = np.percentile(x2, 25) - 1.5 * np.std(x2) high_band_2 = np.percentile(x2, 75) + 1.5 * np.std(x2) x2_cutted = [i for i in x2 if i > low_band_2 and i < high_band_2]
Yechipiri nzira yatafunga pano ndeye bootstrap. Nenzira iyi, chirevo chinogadzirwa sechirevo chezvikamu. Mumuenzaniso wedu, zvinoreva muboka rekutonga zvakaenzana ne10.35, uye boka rekuedza i11.78. Iyo ichiri mhedzisiro iri nani kana ichienzaniswa neyekuwedzera data kugadzirisa.
import pandas as pd def create_bootstrap_samples( sample_list: np.array, sample_size: int, n_samples: int ): # create a list for sample means sample_means = [] # loop n_samples times for i in range(n_samples): # create a bootstrap sample of sample_size with replacement bootstrap_sample = pd.Series(sample_list).sample(n = sample_size, replace = True) # calculate the bootstrap sample mean sample_mean = bootstrap_sample.mean() # add this sample mean to the sample means list sample_means.append(sample_mean) return pd.Series(sample_means) (create_bootstrap_samples(x1, len(x1), 1000).mean(), create_bootstrap_samples(x2, len(x2), 1000).mean())
Kuonekwa kwekunze uye kugadzirisa kwakakosha pakuita sarudzo chaiyo. Ikozvino, nzira dzinosvika nhatu dzinokurumidza uye dzakananga dzinogona kukubatsira kutarisa data usati waongorora.
Nekudaro, zvakakosha kuyeuka kuti zvakaonekwa kunze zvinogona kuve zvisingaite tsika uye chimiro chechiitiko chitsva. Asi imwe nyaya :)