Float ChiScoreLog::compute_score(const Profile& exp_profile, const Profile& model_profile, bool offset) const { IMP_UNUSED(offset); Float c = compute_scale_factor(exp_profile, model_profile); Float chi_square = 0.0; unsigned int profile_size = std::min(model_profile.size(), exp_profile.size()); // compute chi square for (unsigned int k=0; k<profile_size; k++) { // in the theoretical profile the error equals to 1 Float square_error = square(log(exp_profile.get_error(k))); Float weight_tilda = model_profile.get_weight(k) / square_error; Float delta = log(exp_profile.get_intensity(k)) - log(c*model_profile.get_intensity(k)); // Exclude the uncertainty originated from limitation of floating number if(fabs(delta/(log(exp_profile.get_intensity(k)))) >= 1.0e-15) chi_square += weight_tilda * square(delta); } chi_square /= profile_size; return sqrt(chi_square); }
Float ChiScoreLog::compute_score(const Profile& exp_profile, const Profile& model_profile, Float min_q, Float max_q) const { Float c = compute_scale_factor(exp_profile, model_profile); Float chi_square = 0.0; unsigned int profile_size = std::min(model_profile.size(), exp_profile.size()); unsigned int interval_size=0; // compute chi square for (unsigned int k=0; k<profile_size; k++) { if(exp_profile.get_q(k) > max_q) break; if(exp_profile.get_q(k) >= min_q) { // in the theoretical profile the error equals to 1 Float square_error = square(log(exp_profile.get_error(k))); Float weight_tilda = model_profile.get_weight(k) / square_error; Float delta = log(exp_profile.get_intensity(k)) - log(c*model_profile.get_intensity(k)); // Exclude the uncertainty originated from limitation of floating number if(fabs(delta/(log(exp_profile.get_intensity(k)))) >= 1.0e-15) { chi_square += weight_tilda * square(delta); interval_size++; } } } if(interval_size > 0) chi_square /= interval_size; return sqrt(chi_square); }
static void compute_viewport(window_state_t *state, viewport_t *v) { stream_t *stream = state->stream; double min; double max; double unit; compute_scale_factor(state, &v->sx, &v->sy); v->w = gtk_widget_get_allocated_width(state->drawing_area); v->h = gtk_widget_get_allocated_height(state->drawing_area); v->uox = 0.0f; v->uoy = 0.0f; v->udx = v->w; v->udy = v->h; v->uw = v->w; v->uh = v->h; v->updx = 1.0f; v->updy = 1.0f; // Find equivalent for the origin and window size in user coordinates cairo_matrix_transform_point(&state->window_to_user_inv, &v->uox, &v->uoy); cairo_matrix_transform_point(&state->window_to_user_inv, &v->udx, &v->udy); cairo_matrix_transform_distance(&state->window_to_user_inv, &v->uw, &v->uh); cairo_matrix_transform_distance(&state->window_to_user_inv, &v->updx, &v->updy); v->sox = v->uox; v->soy = v->uoy; v->sdx = v->udx; v->sdy = v->udy; v->sw = v->uw; v->sh = v->uh; v->spdx = v->updx; v->spdy = v->updy; // Find equivalent for the origin and window size in scaled coordinates cairo_matrix_transform_point(&state->user_to_scaled_inv, &v->sox, &v->soy); cairo_matrix_transform_point(&state->user_to_scaled_inv, &v->sdx, &v->sdy); cairo_matrix_transform_distance(&state->user_to_scaled_inv, &v->sw, &v->sh); cairo_matrix_transform_distance(&state->user_to_scaled_inv, &v->spdx, &v->spdy); if (v->soy < v->sdy) { min = v->soy; max = v->sdy; } else { min = v->sdy; max = v->soy; } // Determine offsets of first wedge in view and first wedge out of view unit = state->wedge_height * stream->sample_rate / powf(2.0f, v->sy); v->start = floor((min * stream->sample_rate) / unit) * unit; v->end = (floor((max * stream->sample_rate) / unit) + 1.0f) * unit; v->skip = unit; // Offsets of stream v->stream_start = 0; v->stream_end = stream->n_samples; }