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

consider features that are useful for inference #89

Open
grahamgower opened this issue Jun 29, 2021 · 3 comments
Open

consider features that are useful for inference #89

grahamgower opened this issue Jun 29, 2021 · 3 comments

Comments

@grahamgower
Copy link
Member

We've discussed this in various places. Here are the obvious links I found.
popsim-consortium/demes-python#63
popsim-consortium/demes-paper#3

@grahamgower
Copy link
Member Author

grahamgower commented Jul 15, 2021

Some examples of schemes currently used to specify demographic model parameters (for inference or simulation generally). Feel free to edit this post (and maybe comment to ping folks about an update).

Program URI Format Expressions Distributions Bounds Constraints Notes
moments docs YAML no n/a yes yes Works with Demes already (by design).
ms site N/A no no no no Accepts the special value "tbs" for any parameter on the command line. The space-separated parameter values are then read from stdin, one line per simulation replicate. Parameter distributions are managed by the user.
fast/simcoal/2 manual (pg 35) custom yes uniform, log-uniform yes yes Parameters are specified as a variable name in a "template" input file that matches the regular text-based input file format. A separate "estimation" file describes parameter type (int/float), distribution, and bounds. The design looks very complicated and there are many quirks that may lead to user error.
legofit docs custom yes uniform yes yes Free parameters are given default ranges if not specified. Variables have a type, e.g. "time" or "haploid population size". The design looks very clean.

@grahamgower
Copy link
Member Author

https://www.yaml.info/learn/index.html#config highlights how Github Actions workflow YAML files use ${{ <expression> }} inside the YAML to include a minilanguage that e.g. permits references to variables defined elsewhere in the YAML (without doing alias/anchor nastiness). The key point, is that the ${{ foo }} syntax was chosen because it is parsed as a YAML string. If one was so inclined, this approach could be used by an inference framework to refer to variables and include simple arithmetic.

time_units: generations
variables:
- {name: N0, lower: 50, upper: 1000}
- {name: T0, lower: 100, upper: 200}
demes:
- name: A
  epochs:
  - end_time: ${{ T0 }}
    start_size: ${{ N0 }}
  - end_time: 0
    start_size: ${{ 10 * N0 }}

And maybe allowing non-free parameters to refer to other parameters:

time_units: generations
variables:
- {name: N0, lower: 50, upper: 1000}
- {name: T0, value: ${{ 5 * N0 }} }
demes:
- name: A
  epochs:
  - end_time: ${{ T0 }}
    start_size: ${{ N0 }}
  - end_time: 0
    start_size: ${{ 10 * N0 }}

The idea here would be that a static Demes model could be constructed from such a "template" (E.g. using pyparsing to parse the expression minilanguage). I'm not convinced we want to have such a thing in the Demes spec, but I can certainly imagine having a python library that implements this.

@grahamgower
Copy link
Member Author

grahamgower commented Jul 29, 2021

There's no reason we need to be thinking about our own solution, or about YAML either. The desire to have some kind of templating framework for serialised data seems to be a fairly widespread phenomenon. Check out Jsonnet, a turing-complete templating language that is also an extension to JSON!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant