New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make performance linear #1

Closed
idontgetoutmuch opened this Issue Jan 3, 2017 · 1 comment

Comments

Projects
None yet
2 participants
@idontgetoutmuch

idontgetoutmuch commented Jan 3, 2017

Since I just did this, I thought I would share it with you.

transformed parameters {
  vector[N] log_p;
  {
    vector[N+1] log_p_e;
    vector[N+1] log_p_l;
    log_p_e[1] = 0;
    log_p_l[1] = 0;
    for (i in 1:N) {
      log_p_e[i + 1] = log_p_e[i] + normal_lpdf(D[i] | mu1, sigma1);
      log_p_l[i + 1] = log_p_l[i] + normal_lpdf(D[i] | mu2, sigma2);
    }
    log_p = rep_vector(-log(N) + log_p_l[N + 1], N) + head(log_p_e, N) - head(log_p_l, N);
  }
}

@gmodena gmodena self-assigned this Mar 19, 2017

@gmodena

This comment has been minimized.

Show comment
Hide comment
@gmodena

gmodena Mar 19, 2017

Owner

Hi @idontgetoutmuch,
thanks for the contribution. I incorporated your suggestion in the model, and updated the article.

Owner

gmodena commented Mar 19, 2017

Hi @idontgetoutmuch,
thanks for the contribution. I incorporated your suggestion in the model, and updated the article.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment