void draw_2d_gaussian(dyv *mu,dym *cov,dyv *lo,dyv *hi) { surgraph *sg; gauss_info gi[1]; char buff[1000]; gi -> mu = mu; gi -> cov_inv = mk_invert_dym(cov); gi -> cov_determinant = dym_determinant(cov); sprintf(buff,"mu = (%g,%g), cov=((%g,%g),(%g,%g))", dyv_ref(mu,0),dyv_ref(mu,1), dym_ref(cov,0,0),dym_ref(cov,0,1), dym_ref(cov,1,0),dym_ref(cov,1,1)); sg = mk_surgraph_from_2d_function(gauss_height_fn,(char *)gi, 30,30,buff,"x1","x2",dyv_ref(lo,0),dyv_ref(lo,1), dyv_ref(hi,0),dyv_ref(hi,1)); ag_on("gauss.ps"); render_surgraph(sg); ag_off(); free_dym(gi->cov_inv); free_surgraph(sg); }
/* Draws a histogram with N bars where N = dym_rows(freqs) Each bar is compartmented into K subbars, on top of each other, where K = dym_cols(freqs) and the j'th subcomponent of the i'th bar has height = dym_ref(freqs,i,j) and is on top of the j-1'th subcomponent. The i'th bar is centered on x=xlo + (i+0.5) * (xhi - xlo) / num_bars */ void ongr_plot_hist(frame *fr,ongr *on,dym *freqs,bool ratio) { int i; int num_bars = dym_rows(freqs); int num_classes = dym_cols(freqs); double xlo = on -> x_axis.lo; double xhi = on -> x_axis.hi; double bar_width = 0.9 * (xhi - xlo) / num_bars; for ( i = 0 ; i < num_bars ; i++ ) { double xmid = xlo + (i + 0.5) * (xhi - xlo) / num_bars; double x1 = xmid - bar_width/2; double x2 = xmid + bar_width/2; int j; double sumy = 0.0; double total_sum_y = real_max(1e-5,dym_sum_row(freqs,i)); for ( j = 0 ; j < num_classes ; j++ ) { double y1 = sumy; double dy = dym_ref(freqs,i,j) / ((ratio) ? (total_sum_y/100.0) : 1.0); double y2 = sumy + dy; int amut_col = color_code_to_ag_color(j); ongr_colored_bordered_rectangle(fr,on,x1,y1,x2,y2,amut_col); sumy = y2; } } }
void lr_compute_n_from_dym( const dym *M, double b0, dyv *b, dyv *n) { int numrows, numgood, row, j; double sum; numrows = dym_rows( M); numgood = dyv_size(b); for (row=0; row < numrows; ++row) { sum = 0.0; for (j=0; j<numgood; ++j) sum += dym_ref( M, row, j) * dyv_ref( b, j); sum += b0; dyv_set( n, row, sum); } return; }