Skip to content
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

replicates should >= 0 #350

Closed
walterxie opened this issue May 15, 2023 · 3 comments
Closed

replicates should >= 0 #350

walterxie opened this issue May 15, 2023 · 3 comments
Labels
critical change the bug fix or new feature will significant change the code enhancement New feature or request

Comments

@walterxie
Copy link
Collaborator

walterxie commented May 15, 2023

Add the validation to check if replicates >= 1 when using IID. Otherwise throw IllegalArgumentException (Runtime) and catch at the top level.

Update to replicates >= 0

@walterxie walterxie added the enhancement New feature or request label May 15, 2023
walterxie added a commit that referenced this issue May 15, 2023
walterxie added a commit that referenced this issue May 15, 2023
@bredelings
Copy link

bredelings commented May 15, 2023

Hmm... requiring replicates to be >=1 makes it impossible to have the number of replicates be random.

If that is intentional, perhaps you should also check that replicates is random and complain about that as well?

Also, perhaps you should introduce an iid distribution for when people want to allow replicates to be 0 or 1?

@alexeid

@walterxie
Copy link
Collaborator Author

walterxie commented May 15, 2023

You can sample it from a Poisson distribution, and set min=1. This is an example from Alexei:

// replicates = 1, 2, 3, ...
k ~ Poisson(lambda=1.0, min=1);
pi ~ Dirichlet(conc=[1, 1, 1, 1], replicates=k);
L = length(pi);

But I cannot figure out what replicates=0 means?

@bredelings
Copy link

bredelings commented May 15, 2023

Oops, somehow I misread the issue title as "replicates should be > 1". Sorry. I was thinking that you were going to forbid replicates=1 in order to avoid a choice of how to interpret that. But now I see my mistake.

So, if replicates=1 returns x, then I also do not know what replicates=0 should return.

But if replicates=1 returns [x], then replicates=0 would return [].

The second case makes more sense to me because the return type does not depend on a parameter value. However, this is not as big a deal as I originally thought, since replicates=1 is still allowed.

One question is if there are models where replicates=0 occurs. If we are constructing an n-component mixture model by drawing n replicates from some distribution, then we do need n >= 1.

However, suppose we are looking at the number of change points in some interval. At each change point the evolutionary rate is multiplied by some value. Then we might find the rate at the end of the interval as follows:

n ~ Poisson(lambda)
scaleFactors ~ LogNormal(mu,sigma,replicates=n)
finalRate = initialRate * product(scaleFactors)

If there are no change points (n==0) then we want to get scaleFactors = [] and finalRate = initialRate.

This assumes that the product([]) == 1. I think this is pretty standard.

@walterxie walterxie changed the title replicates should >= 1 replicates should >= 0 May 16, 2023
walterxie added a commit that referenced this issue May 16, 2023
@walterxie walterxie added the critical change the bug fix or new feature will significant change the code label May 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
critical change the bug fix or new feature will significant change the code enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants