{"action":"created","comment":{"url":"https://api.github.com/repos/broadinstitute/gatk-protected/pulls/comments/46375002","id":46375002,"diff_hunk":"@@ -0,0 +1,106 @@\n+package org.broadinstitute.hellbender.utils.mcmc;\n+\n+import org.testng.Assert;\n+import org.testng.annotations.Test;\n+\n+import java.util.Arrays;\n+import java.util.List;\n+\n+/**\n+ * Created by davidben on 11/24/15.\n+ */\n+public class AdaptiveMetropolisSamplerUnitTest {\n+    private static final double BETA_MIN = 0;\n+    private static final double BETA_MAX = 1;\n+    private static final double BETA_START = 0.5;\n+    private static final double INITIAL_STEP_SIZE = 0.1;\n+    private static final EmptyData EMPTY_DATA = new EmptyData();\n+    private static final int NUM_BURN_IN_STEPS = 200;\n+    private static final int NUM_SAMPLES = 500;\n+\n+\n+    // factory for sampling the distribution Beta(a, b) defined on [0,1]\n+    final static GibbsSampler<DoubleState, EmptyData> betaGibbsSampler(final double a, final double b) {\n+        final  Sampler<Double, DoubleState, EmptyData> betaSampler =\n+                new AdaptiveMetropolisSampler<DoubleState, EmptyData>(INITIAL_STEP_SIZE, BETA_MIN, BETA_MAX) {\n+                @Override\n+                protected double proposalLogLikelihood(Double proposal, DoubleState state, EmptyData data) {\n+                    return (a - 1) * Math.log(proposal) + (b - 1) * Math.log(1 - proposal);\n+                }\n+\n+                @Override\n+                protected double currentValue(final DoubleState state) {\n+                    return state.value();\n+                }\n+            };\n+        ParameterizedModel<DoubleState, EmptyData> betaModel =\n+                new ParameterizedModel.GibbsBuilder<>(new DoubleState(BETA_START), EMPTY_DATA, DoubleState.class)\n+                .addParameterSampler(DoubleState.PARAMETER_NAME, betaSampler, Double.class).build();\n+\n+        return new GibbsSampler<>(NUM_BURN_IN_STEPS + NUM_SAMPLES, betaModel);\n+        }\n+\n+\n+    // factory for sampling Gaussian with mean mu and precision lambda\n+    final static GibbsSampler<DoubleState, EmptyData> gaussianGibbsSampler(final double mu, final double lambda) {\n+        final  Sampler<Double, DoubleState, EmptyData> gaussianSampler =\n+                new AdaptiveMetropolisSampler<DoubleState, EmptyData>(INITIAL_STEP_SIZE) {\n+                    @Override\n+                    protected double proposalLogLikelihood(Double proposal, DoubleState state, EmptyData data) {\n+                        final double x = state.value();\n+                        return -(lambda/2)*(proposal-mu)*(proposal-mu);\n+                    }\n+\n+                    @Override\n+                    protected double currentValue(final DoubleState state) {\n+                        return state.value();\n+                    }\n+                };\n+\n+        final ParameterizedModel<DoubleState, EmptyData> gaussianModel =\n+                new ParameterizedModel.GibbsBuilder<>(new DoubleState(BETA_START), EMPTY_DATA, DoubleState.class)\n+                .addParameterSampler(DoubleState.PARAMETER_NAME, gaussianSampler, Double.class).build();\n+\n+        return new GibbsSampler<>(NUM_BURN_IN_STEPS + NUM_SAMPLES, gaussianModel);\n+    }\n+\n+\n+    @Test\n+    public void testBeta() throws Exception {\n+        for (final double a : Arrays.asList(10, 20, 30)) {","path":"src/test/java/org/broadinstitute/hellbender/utils/mcmc/AdaptiveMetropolisSamplerUnitTest.java","position":70,"original_position":70,"commit_id":"4f72f98bccabedd65534c97e41899215a4e234f1","original_commit_id":"2c043744ed8535a4205ff27a634ad309c3129666","user":{"login":"samuelklee","id":11076296,"avatar_url":"https://avatars.githubusercontent.com/u/11076296?v=3","gravatar_id":"","url":"https://api.github.com/users/samuelklee","html_url":"https://github.com/samuelklee","followers_url":"https://api.github.com/users/samuelklee/followers","following_url":"https://api.github.com/users/samuelklee/following{/other_user}","gists_url":"https://api.github.com/users/samuelklee/gists{/gist_id}","starred_url":"https://api.github.com/users/samuelklee/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/samuelklee/subscriptions","organizations_url":"https://api.github.com/users/samuelklee/orgs","repos_url":"https://api.github.com/users/samuelklee/repos","events_url":"https://api.github.com/users/samuelklee/events{/privacy}","received_events_url":"https://api.github.com/users/samuelklee/received_events","type":"User","site_admin":false},"body":"could also use DataProviders here (although it wouldn't save you as many lines of code in this case, could make things a bit more readable---will leave it up to you)","created_at":"2015-12-02T03:57:22Z","updated_at":"2015-12-02T03:57:22Z","html_url":"https://github.com/broadinstitute/gatk-protected/pull/198#discussion_r46375002","pull_request_url":"https://api.github.com/repos/broadinstitute/gatk-protected/pulls/198","_links":{"self":{"href":"https://api.github.com/repos/broadinstitute/gatk-protected/pulls/comments/46375002"},"html":{"href":"https://github.com/broadinstitute/gatk-protected/pull/198#discussion_r46375002"},"pull_request":{"href":"https://api.github.com/repos/broadinstitute/gatk-protected/pulls/198"}}},"pull_request":{"url":"https://api.github.com/repos/broadinstitute/gatk-protected/pulls/198","id":52145072,"html_url":"https://github.com/broadinstitute/gatk-protected/pull/198","diff_url":"https://github.com/broadinstitute/gatk-protected/pull/198.diff","patch_url":"https://github.com/broadinstitute/gatk-protected/pull/198.patch","issue_url":"https://api.github.com/repos/broadinstitute/gatk-protected/issues/198","number":198,"state":"open","locked":false,"title":"Allele Fraction Model","user":{"login":"davidbenjamin","id":8438890,"avatar_url":"https://avatars.githubusercontent.com/u/8438890?v=3","gravatar_id":"","url":"https://api.github.com/users/davidbenjamin","html_url":"https://github.com/davidbenjamin","followers_url":"https://api.github.com/users/davidbenjamin/followers","following_url":"https://api.github.com/users/davidbenjamin/following{/other_user}","gists_url":"https://api.github.com/users/davidbenjamin/gists{/gist_id}","starred_url":"https://api.github.com/users/davidbenjamin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/davidbenjamin/subscriptions","organizations_url":"https://api.github.com/users/davidbenjamin/orgs","repos_url":"https://api.github.com/users/davidbenjamin/repos","events_url":"https://api.github.com/users/davidbenjamin/events{/privacy}","received_events_url":"https://api.github.com/users/davidbenjamin/received_events","type":"User","site_admin":false},"body":"@LeeTL1220 Please look at the organization of classes and other software engineering aspects.","created_at":"2015-11-30T16:23:08Z","updated_at":"2015-12-02T03:57:22Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2246e7baddb3de78114b5cec033deda201b16922","assignee":{"login":"samuelklee","id":11076296,"avatar_url":"https://avatars.githubusercontent.com/u/11076296?v=3","gravatar_id":"","url":"https://api.github.com/users/samuelklee","html_url":"https://github.com/samuelklee","followers_url":"https://api.github.com/users/samuelklee/followers","following_url":"https://api.github.com/users/samuelklee/following{/other_user}","gists_url":"https://api.github.com/users/samuelklee/gists{/gist_id}","starred_url":"https://api.github.com/users/samuelklee/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/samuelklee/subscriptions","organizations_url":"https://api.github.com/users/samuelklee/orgs","repos_url":"https://api.github.com/users/samuelklee/repos","events_url":"https://api.github.com/users/samuelklee/events{/privacy}","received_events_url":"https://api.github.com/users/samuelklee/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/broadinstitute/gatk-protected/pulls/198/commits","review_comments_url":"https://api.github.com/repos/broadinstitute/gatk-protected/pulls/198/comments","review_comment_url":"https://api.github.com/repos/broadinstitute/gatk-protected/pulls/comments{/number}","comments_url":"https://api.github.com/repos/broadinstitute/gatk-protected/issues/198/comments","statuses_url":"https://api.github.com/repos/broadinstitute/gatk-protected/statuses/4f72f98bccabedd65534c97e41899215a4e234f1","head":{"label":"broadinstitute:db_ACS_model","ref":"db_ACS_model","sha":"4f72f98bccabedd65534c97e41899215a4e234f1","user":{"login":"broadinstitute","id":393552,"avatar_url":"https://avatars.githubusercontent.com/u/393552?v=3","gravatar_id":"","url":"https://api.github.com/users/broadinstitute","html_url":"https://github.com/broadinstitute","followers_url":"https://api.github.com/users/broadinstitute/followers","following_url":"https://api.github.com/users/broadinstitute/following{/other_user}","gists_url":"https://api.github.com/users/broadinstitute/gists{/gist_id}","starred_url":"https://api.github.com/users/broadinstitute/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/broadinstitute/subscriptions","organizations_url":"https://api.github.com/users/broadinstitute/orgs","repos_url":"https://api.github.com/users/broadinstitute/repos","events_url":"https://api.github.com/users/broadinstitute/events{/privacy}","received_events_url":"https://api.github.com/users/broadinstitute/received_events","type":"Organization","site_admin":false},"repo":{"id":34413897,"name":"gatk-protected","full_name":"broadinstitute/gatk-protected","owner":{"login":"broadinstitute","id":393552,"avatar_url":"https://avatars.githubusercontent.com/u/393552?v=3","gravatar_id":"","url":"https://api.github.com/users/broadinstitute","html_url":"https://github.com/broadinstitute","followers_url":"https://api.github.com/users/broadinstitute/followers","following_url":"https://api.github.com/users/broadinstitute/following{/other_user}","gists_url":"https://api.github.com/users/broadinstitute/gists{/gist_id}","starred_url":"https://api.github.com/users/broadinstitute/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/broadinstitute/subscriptions","organizations_url":"https://api.github.com/users/broadinstitute/orgs","repos_url":"https://api.github.com/users/broadinstitute/repos","events_url":"https://api.github.com/users/broadinstitute/events{/privacy}","received_events_url":"https://api.github.com/users/broadinstitute/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/broadinstitute/gatk-protected","description":"GATK4 development of the license-protected part of the toolkit","fork":false,"url":"https://api.github.com/repos/broadinstitute/gatk-protected","forks_url":"https://api.github.com/repos/broadinstitute/gatk-protected/forks","keys_url":"https://api.github.com/repos/broadinstitute/gatk-protected/keys{/key_id}","collaborators_url":"https://api.github.com/repos/broadinstitute/gatk-protected/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/broadinstitute/gatk-protected/teams","hooks_url":"https://api.github.com/repos/broadinstitute/gatk-protected/hooks","issue_events_url":"https://api.github.com/repos/broadinstitute/gatk-protected/issues/events{/number}","events_url":"https://api.github.com/repos/broadinstitute/gatk-protected/events","assignees_url":"https://api.github.com/repos/broadinstitute/gatk-protected/assignees{/user}","branches_url":"https://api.github.com/repos/broadinstitute/gatk-protected/branches{/branch}","tags_url":"https://api.github.com/repos/broadinstitute/gatk-protected/tags","blobs_url":"https://api.github.com/repos/broadinstitute/gatk-protected/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/broadinstitute/gatk-protected/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/broadinstitute/gatk-protected/git/refs{/sha}","trees_url":"https://api.github.com/repos/broadinstitute/gatk-protected/git/trees{/sha}","statuses_url":"https://api.github.com/repos/broadinstitute/gatk-protected/statuses/{sha}","languages_url":"https://api.github.com/repos/broadinstitute/gatk-protected/languages","stargazers_url":"https://api.github.com/repos/broadinstitute/gatk-protected/stargazers","contributors_url":"https://api.github.com/repos/broadinstitute/gatk-protected/contributors","subscribers_url":"https://api.github.com/repos/broadinstitute/gatk-protected/subscribers","subscription_url":"https://api.github.com/repos/broadinstitute/gatk-protected/subscription","commits_url":"https://api.github.com/repos/broadinstitute/gatk-protected/commits{/sha}","git_commits_url":"https://api.github.com/repos/broadinstitute/gatk-protected/git/commits{/sha}","comments_url":"https://api.github.com/repos/broadinstitute/gatk-protected/comments{/number}","issue_comment_url":"https://api.github.com/repos/broadinstitute/gatk-protected/issues/comments{/number}","contents_url":"https://api.github.com/repos/broadinstitute/gatk-protected/contents/{+path}","compare_url":"https://api.github.com/repos/broadinstitute/gatk-protected/compare/{base}...{head}","merges_url":"https://api.github.com/repos/broadinstitute/gatk-protected/merges","archive_url":"https://api.github.com/repos/broadinstitute/gatk-protected/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/broadinstitute/gatk-protected/downloads","issues_url":"https://api.github.com/repos/broadinstitute/gatk-protected/issues{/number}","pulls_url":"https://api.github.com/repos/broadinstitute/gatk-protected/pulls{/number}","milestones_url":"https://api.github.com/repos/broadinstitute/gatk-protected/milestones{/number}","notifications_url":"https://api.github.com/repos/broadinstitute/gatk-protected/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/broadinstitute/gatk-protected/labels{/name}","releases_url":"https://api.github.com/repos/broadinstitute/gatk-protected/releases{/id}","created_at":"2015-04-22T20:24:45Z","updated_at":"2015-11-24T15:27:35Z","pushed_at":"2015-12-02T01:56:20Z","git_url":"git://github.com/broadinstitute/gatk-protected.git","ssh_url":"git@github.com:broadinstitute/gatk-protected.git","clone_url":"https://github.com/broadinstitute/gatk-protected.git","svn_url":"https://github.com/broadinstitute/gatk-protected","homepage":null,"size":48553,"stargazers_count":3,"watchers_count":3,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":50,"forks":0,"open_issues":50,"watchers":3,"default_branch":"master"}},"base":{"label":"broadinstitute:master","ref":"master","sha":"a33a4f5633a8ca66e6839dd6f9459f5aacd9aeb5","user":{"login":"broadinstitute","id":393552,"avatar_url":"https://avatars.githubusercontent.com/u/393552?v=3","gravatar_id":"","url":"https://api.github.com/users/broadinstitute","html_url":"https://github.com/broadinstitute","followers_url":"https://api.github.com/users/broadinstitute/followers","following_url":"https://api.github.com/users/broadinstitute/following{/other_user}","gists_url":"https://api.github.com/users/broadinstitute/gists{/gist_id}","starred_url":"https://api.github.com/users/broadinstitute/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/broadinstitute/subscriptions","organizations_url":"https://api.github.com/users/broadinstitute/orgs","repos_url":"https://api.github.com/users/broadinstitute/repos","events_url":"https://api.github.com/users/broadinstitute/events{/privacy}","received_events_url":"https://api.github.com/users/broadinstitute/received_events","type":"Organization","site_admin":false},"repo":{"id":34413897,"name":"gatk-protected","full_name":"broadinstitute/gatk-protected","owner":{"login":"broadinstitute","id":393552,"avatar_url":"https://avatars.githubusercontent.com/u/393552?v=3","gravatar_id":"","url":"https://api.github.com/users/broadinstitute","html_url":"https://github.com/broadinstitute","followers_url":"https://api.github.com/users/broadinstitute/followers","following_url":"https://api.github.com/users/broadinstitute/following{/other_user}","gists_url":"https://api.github.com/users/broadinstitute/gists{/gist_id}","starred_url":"https://api.github.com/users/broadinstitute/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/broadinstitute/subscriptions","organizations_url":"https://api.github.com/users/broadinstitute/orgs","repos_url":"https://api.github.com/users/broadinstitute/repos","events_url":"https://api.github.com/users/broadinstitute/events{/privacy}","received_events_url":"https://api.github.com/users/broadinstitute/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/broadinstitute/gatk-protected","description":"GATK4 development of the license-protected part of the toolkit","fork":false,"url":"https://api.github.com/repos/broadinstitute/gatk-protected","forks_url":"https://api.github.com/repos/broadinstitute/gatk-protected/forks","keys_url":"https://api.github.com/repos/broadinstitute/gatk-protected/keys{/key_id}","collaborators_url":"https://api.github.com/repos/broadinstitute/gatk-protected/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/broadinstitute/gatk-protected/teams","hooks_url":"https://api.github.com/repos/broadinstitute/gatk-protected/hooks","issue_events_url":"https://api.github.com/repos/broadinstitute/gatk-protected/issues/events{/number}","events_url":"https://api.github.com/repos/broadinstitute/gatk-protected/events","assignees_url":"https://api.github.com/repos/broadinstitute/gatk-protected/assignees{/user}","branches_url":"https://api.github.com/repos/broadinstitute/gatk-protected/branches{/branch}","tags_url":"https://api.github.com/repos/broadinstitute/gatk-protected/tags","blobs_url":"https://api.github.com/repos/broadinstitute/gatk-protected/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/broadinstitute/gatk-protected/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/broadinstitute/gatk-protected/git/refs{/sha}","trees_url":"https://api.github.com/repos/broadinstitute/gatk-protected/git/trees{/sha}","statuses_url":"https://api.github.com/repos/broadinstitute/gatk-protected/statuses/{sha}","languages_url":"https://api.github.com/repos/broadinstitute/gatk-protected/languages","stargazers_url":"https://api.github.com/repos/broadinstitute/gatk-protected/stargazers","contributors_url":"https://api.github.com/repos/broadinstitute/gatk-protected/contributors","subscribers_url":"https://api.github.com/repos/broadinstitute/gatk-protected/subscribers","subscription_url":"https://api.github.com/repos/broadinstitute/gatk-protected/subscription","commits_url":"https://api.github.com/repos/broadinstitute/gatk-protected/commits{/sha}","git_commits_url":"https://api.github.com/repos/broadinstitute/gatk-protected/git/commits{/sha}","comments_url":"https://api.github.com/repos/broadinstitute/gatk-protected/comments{/number}","issue_comment_url":"https://api.github.com/repos/broadinstitute/gatk-protected/issues/comments{/number}","contents_url":"https://api.github.com/repos/broadinstitute/gatk-protected/contents/{+path}","compare_url":"https://api.github.com/repos/broadinstitute/gatk-protected/compare/{base}...{head}","merges_url":"https://api.github.com/repos/broadinstitute/gatk-protected/merges","archive_url":"https://api.github.com/repos/broadinstitute/gatk-protected/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/broadinstitute/gatk-protected/downloads","issues_url":"https://api.github.com/repos/broadinstitute/gatk-protected/issues{/number}","pulls_url":"https://api.github.com/repos/broadinstitute/gatk-protected/pulls{/number}","milestones_url":"https://api.github.com/repos/broadinstitute/gatk-protected/milestones{/number}","notifications_url":"https://api.github.com/repos/broadinstitute/gatk-protected/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/broadinstitute/gatk-protected/labels{/name}","releases_url":"https://api.github.com/repos/broadinstitute/gatk-protected/releases{/id}","created_at":"2015-04-22T20:24:45Z","updated_at":"2015-11-24T15:27:35Z","pushed_at":"2015-12-02T01:56:20Z","git_url":"git://github.com/broadinstitute/gatk-protected.git","ssh_url":"git@github.com:broadinstitute/gatk-protected.git","clone_url":"https://github.com/broadinstitute/gatk-protected.git","svn_url":"https://github.com/broadinstitute/gatk-protected","homepage":null,"size":48553,"stargazers_count":3,"watchers_count":3,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":50,"forks":0,"open_issues":50,"watchers":3,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/broadinstitute/gatk-protected/pulls/198"},"html":{"href":"https://github.com/broadinstitute/gatk-protected/pull/198"},"issue":{"href":"https://api.github.com/repos/broadinstitute/gatk-protected/issues/198"},"comments":{"href":"https://api.github.com/repos/broadinstitute/gatk-protected/issues/198/comments"},"review_comments":{"href":"https://api.github.com/repos/broadinstitute/gatk-protected/pulls/198/comments"},"review_comment":{"href":"https://api.github.com/repos/broadinstitute/gatk-protected/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/broadinstitute/gatk-protected/pulls/198/commits"},"statuses":{"href":"https://api.github.com/repos/broadinstitute/gatk-protected/statuses/4f72f98bccabedd65534c97e41899215a4e234f1"}}}}