void procstat_sandbox_methods(struct procstat *procstat, struct kinfo_proc *kipp) { struct sandbox_method_stat *smsp, *smsp_free; size_t len; u_int i; if (!hflag) { printf("%5s %-10s %-20s %-10s %6s %5s %8s %8s", "PID", "COMM", "CLASS", "METHOD", "INVOKE", "FAULT", "LMIN", "LMAX"); if (Xflag) printf(" %8s %8s %8s %8s", "SMIN", "SMAX", "SMEAN", "SMEDIAN"); printf("\n"); } smsp_free = smsp = procstat_getsbmethods(procstat, kipp, &len); if (smsp == NULL) return; for (i = 0; i < (len / sizeof(*smsp)); i++, smsp++) { if (smsp->sms_methodid == SANDBOX_METHODID_FREE) continue; printf("%5d ", kipp->ki_pid); printf("%-10s ", kipp->ki_comm); printf("%-20s ", smsp->sms_class_name); printf("%-10s ", smsp->sms_method_name); printf("%6jd ", (uintmax_t)smsp->sms_stat_invoke); printf("%5jd ", (uintmax_t)smsp->sms_stat_fault); printf("%8jd ", (uintmax_t)smsp->sms_stat_minrun); printf("%8jd", (uintmax_t)smsp->sms_stat_maxrun); if (Xflag) { printf(" %8jd", sample_min(SANDBOX_METHOD_MAXSAMPVEC, smsp->sms_stat_sampvec)); printf(" %8jd", sample_max(SANDBOX_METHOD_MAXSAMPVEC, smsp->sms_stat_sampvec)); printf(" %8jd", sample_mean(SANDBOX_METHOD_MAXSAMPVEC, smsp->sms_stat_sampvec)); printf(" %8jd", sample_median( SANDBOX_METHOD_MAXSAMPVEC, smsp->sms_stat_sampvec)); } printf("\n"); } procstat_freesbmethods(procstat, smsp_free); }
int main(int argv, char** argc) { printf("\n\nRunning code for question 1.11:\n\n"); int train_area1[4] = {150-1,330-1,264-1,328-1}; /*read images from file*/ pnm_img * kande1 = pnm_read(IMG_IN_DIR "kande1.pnm"), * kande2 = pnm_read(IMG_IN_DIR "kande2.pnm"); pnm_img * train_img =pnm_subimage(kande1, train_area1); mtrx * train_set = img2train_set(train_img); vect * s_mean = sample_mean(train_set); mtrx * s_cov = sample_cov(train_set, s_mean); double* map = (double*)malloc(kande2->width*kande2->height*sizeof(double)); pdf_map(kande2, s_mean,s_cov,&map); vect* w_mean = weighted_avg_pos(kande2, map); pnm_pixmap p = {0,255,0}; for (int x = -2; x<4; x++) for (int y=-2; y<4; y++) { pnm_set_pixel(kande2, (*w_mean->data)+x, *(w_mean->data+1)+y, &p); } // pnm_write(kande1, IMG_OUT_DIR"cas10center.pnm"); mtrx* w_cov = weighted_2dcov(map, w_mean, kande2); FILE* fp = fopen(TEX_OUT_DIR"c11.tex", "w"); vect2tex(w_mean, "celevenwmean", fp); mtrx2tex(w_cov, "celevenwcov", fp); fclose(fp); gplot_img2splot(kande2, 0 ,TEX_OUT_DIR"case11.kande2.gnuplot.dat"); gplot_pdf2splot(w_mean, w_cov, kande2, 5, TEX_OUT_DIR"case11.pdf.gnuplot.dat"); gsl_matrix_free(train_set); gsl_matrix_free(s_cov); gsl_vector_free(s_mean); pnm_destroy(kande1); pnm_destroy(train_img); }
calc_data do_cucl(int k, int n, double m, double g, QVector<double> trend_m, QVector<double> trend_s, double level) { QVector<QVector<double>> matrix = createMatrix(k,n,m,g,trend_m,trend_s); QVector<double> y; for(auto sample : matrix) { y.push_back(sample_mean(sample)); } QVector<double> x; for(int i = 0; i<k;i++) { x.push_back(i); } QVector<bool> u = U(y); QVector<bool> l = L(y); int a = Asum(u,l); int b = Bsum(u,l); //Тренд средних double F = f(k); double t_stat_mean = a/F; double L = l_const(k); double t_stat_s = (b-F*F)/L; double t_cr = t_test_cr(k,level); qDebug() << "a" << a; qDebug() << "b" << b; qDebug() << "t mean" << t_stat_mean; qDebug() << "t s" << t_stat_s; qDebug() << t_cr; calc_data data; data.x=x; data.y=y; data.t_A=t_stat_mean; data.t_B=t_stat_s; data.t_cr=t_cr; data.A=a; data.B=b; return data; }
static int rx_cal_dc_off(struct rx_cal *cal, struct gain_mode *gains, int16_t *dc_i, int16_t *dc_q) { int status = BLADERF_ERR_UNEXPECTED; float mean_i, mean_q; status = load_gains(cal, gains); if (status != 0) { return status; } status = rx_samples(cal->dev, cal->samples, cal->num_samples, &cal->ts, RX_CAL_TS_INC); if (status != 0) { return status; } sample_mean(cal->samples, cal->num_samples, &mean_i, &mean_q); *dc_i = float_to_int16(mean_i); *dc_q = float_to_int16(mean_q); return 0; }
void report_xvalid(double *xdata, double *xpred, double *xdiff, double *xstd, double *xzscore, int ndata, int var) { /* * DATE: Tue Oct 6 11:55:44 MET 1992 * BY : Edzer J. Pebesma * PURPOSE: report summary statistics of these five lists * SIDE EFFECTS: none */ int i, nXdata = 0, nXpred = 0, nXdiff = 0, n_std = 0, nZscore = 0, compare(const double *a, const double *b); double min[5], max[5], p25[5], p75[5], p50[5], mean[5], std[5]; double corr = 0.0; set_mv_double(&corr); calc_r(xdata, xpred, ndata, &corr); for (i = 0; i < 5; i ++) { set_mv_double(&(min[i])); set_mv_double(&(p25[i])); set_mv_double(&(p50[i])); set_mv_double(&(p75[i])); set_mv_double(&(max[i])); set_mv_double(&(mean[i])); set_mv_double(&(std[i])); } /* select not missing values, put mv's at the end: */ /* sorting arrays: */ qsort(xdata, (size_t) ndata, sizeof(double), (int (*)(const void *,const void *)) compare); while (!is_mv_double(&(xdata[nXdata])) && nXdata < ndata) nXdata++; qsort(xpred, (size_t) ndata, sizeof(double), (int (*)(const void *,const void *)) compare); while (!is_mv_double(&(xpred[nXpred])) && nXpred < ndata) nXpred++; qsort(xdiff, (size_t) ndata, sizeof(double), (int (*)(const void *,const void *)) compare); while (!is_mv_double(&(xdiff[nXdiff])) && nXdiff < ndata) nXdiff++; if (var) { /* do everything for xstd and xzscore */ qsort(xstd, (size_t) ndata, sizeof(double), (int (*)(const void *,const void *)) compare); while ((! is_mv_double(&(xstd[n_std]))) && (n_std < ndata)) n_std++; qsort(xzscore, (size_t) ndata, sizeof(double), (int (*)(const void *,const void *)) compare); while ((! is_mv_double(&(xzscore[nZscore]))) && (nZscore < ndata)) nZscore++; } /* calculate statistics: */ if (nXdata) { min[0]=xdata[0]; max[0]=xdata[nXdata-1]; mean[0] = sample_mean(xdata, nXdata); if (nXdata > 1) { p25[0]=est_quant(xdata, 0.25, nXdata); p50[0]=est_quant(xdata, 0.5, nXdata); p75[0]=est_quant(xdata, 0.75, nXdata); std[0] = sample_std(xdata, mean[0], nXdata); } } if (nXpred) { min[1]=xpred[0]; max[1]=xpred[nXpred-1]; mean[1] = sample_mean(xpred, nXpred); if (nXpred > 1) { p25[1]=est_quant(xpred, 0.25, nXpred); p50[1]=est_quant(xpred, 0.5, nXpred); p75[1]=est_quant(xpred, 0.75, nXpred); std[1] = sample_std(xpred, mean[1], nXpred); } } if (nXdiff) { min[2]=xdiff[0]; max[2]=xdiff[nXdiff-1]; mean[2] = sample_mean(xdiff, nXdiff); if (nXdiff > 1) { p25[2]=est_quant(xdiff, 0.25, nXdiff); p50[2]=est_quant(xdiff, 0.5, nXdiff); p75[2]=est_quant(xdiff, 0.75, nXdiff); std[2] = sample_std(xdiff, mean[2], nXdiff); } } if (var) { if (n_std) { min[3]=xstd[0]; max[3]=xstd[n_std-1]; mean[3] = sample_mean(xstd, n_std); if (n_std > 1) { p25[3]=est_quant(xstd, 0.25, n_std); p50[3]=est_quant(xstd, 0.5, n_std); p75[3]=est_quant(xstd, 0.75, n_std); std[3] = sample_std(xstd, mean[3], n_std); } } if (nZscore) { min[4]=xzscore[0]; max[4]=xzscore[nZscore-1]; mean[4] = sample_mean(xzscore, nZscore); if (nZscore > 1) { p25[4]=est_quant(xzscore, 0.25, nZscore); p50[4]=est_quant(xzscore, 0.5, nZscore); p75[4]=est_quant(xzscore, 0.75, nZscore); std[4] = sample_std(xzscore, mean[4], nZscore); } } } /* output: */ printlog("corr(Obs, Pred): %s [%s]\n\n", my_dtoa("%6.4g", &corr), method_string(get_method())); printlog(" observed predicted pred.-obs. pred.std. zscore\n"); printlog("======================================================================\n"); printlog("%-10s%12s", "minimum", my_dtoa("%6.4g", &(min[0]))); printlog("%12s", my_dtoa("%6.4g", &(min[1]))); printlog("%12s", my_dtoa("%6.4g", &(min[2]))); printlog("%12s", my_dtoa("%6.4g", &(min[3]))); printlog("%12s\n", my_dtoa("%6.4g", &(min[4]))); printlog("%-10s%12s", "1st q.", my_dtoa("%6.4g", &(p25[0]))); printlog("%12s", my_dtoa("%6.4g", &(p25[1]))); printlog("%12s", my_dtoa("%6.4g", &(p25[2]))); printlog("%12s", my_dtoa("%6.4g", &(p25[3]))); printlog("%12s\n", my_dtoa("%6.4g", &(p25[4]))); printlog("%-10s%12s", "median", my_dtoa("%6.4g", &(p50[0]))); printlog("%12s", my_dtoa("%6.4g", &(p50[1]))); printlog("%12s", my_dtoa("%6.4g", &(p50[2]))); printlog("%12s", my_dtoa("%6.4g", &(p50[3]))); printlog("%12s\n", my_dtoa("%6.4g", &(p50[4]))); printlog("%-10s%12s", "3rd q.", my_dtoa("%6.4g", &(p75[0]))); printlog("%12s", my_dtoa("%6.4g", &(p75[1]))); printlog("%12s", my_dtoa("%6.4g", &(p75[2]))); printlog("%12s", my_dtoa("%6.4g", &(p75[3]))); printlog("%12s\n", my_dtoa("%6.4g", &(p75[4]))); printlog("%-10s%12s", "maximum", my_dtoa("%6.4g", &(max[0]))); printlog("%12s", my_dtoa("%6.4g", &(max[1]))); printlog("%12s", my_dtoa("%6.4g", &(max[2]))); printlog("%12s", my_dtoa("%6.4g", &(max[3]))); printlog("%12s\n\n", my_dtoa("%6.4g", &(max[4]))); printlog("%-10s%12d%12d%12d%12d%12d\n", "n", nXdata, nXpred, nXdiff, n_std, nZscore); printlog("%-10s%12s", "mean", my_dtoa("%6.4g", &(mean[0]))); printlog("%12s", my_dtoa("%6.4g", &(mean[1]))); printlog("%12s", my_dtoa("%6.4g", &(mean[2]))); printlog("%12s", my_dtoa("%6.4g", &(mean[3]))); printlog("%12s\n", my_dtoa("%6.4g", &(mean[4]))); printlog("%-10s%12s", "std.dev.", my_dtoa("%6.4g", &(std[0]))); printlog("%12s", my_dtoa("%6.4g", &(std[1]))); printlog("%12s", my_dtoa("%6.4g", &(std[2]))); printlog("%12s", my_dtoa("%6.4g", &(std[3]))); printlog("%12s\n", my_dtoa("%6.4g", &(std[4]))); return; }
Dtype sample_mean(const int* const seqs) { return sample_mean(seqs, sample_size_); }