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

Generate artificial discrete trajectories for testing purposes #177

Merged
merged 97 commits into from
Oct 13, 2023

Conversation

andthum
Copy link
Owner

@andthum andthum commented Jul 20, 2023

Generate artificial discrete trajectories for testing purposes

Type of change

  • Change of core package.
  • Change of scripts.
  • Bug fix.
  • New feature.
  • Code refactoring.
  • Dependency update.
  • Documentation update.
  • Maintenance.
  • Other: Description.
  • Non-breaking (backward-compatible) change.
  • Breaking (non-backward-compatible) change.

Proposed changes

Bug fixes

  • Fix a ZeroDivisionError in the function mdtools.run_time_info.dtrj_trans_info_str when the total number of state transitions is zero. Return np.inf in this case.

New features

  • Create a script misc/dtrj_lifetimes/plot_gengamma.py that plots the PDF, CDF, survival function and hazard function of the generalized gamma distribution or the Burr Type XII for a given set of shape and scale parameters.

  • Create a new script misc/dtrj_lifetimes/generate_dtrj.py that generates an artificial discrete trajectory with a given number of states with a given lifetime distribution. This script was written to test different methods to calculate state lifetimes from discrete trajectories (specifically mdtools.dtrj.lifetimes, mdtools.dtrj.trans_rate, mdtools.dtrj.remain_prob).

  • Create a new script misc/dtrj_lifetimes/compare_dtrj_lifetime_methods.py that compares state lifetimes calculated from a discrete trajectory using different methods (mdtools.dtrj.lifetimes, mdtools.dtrj.trans_rate, mdtools.dtrj.remain_prob).

  • Create a new script misc/dtrj_lifetimes/plot_lifetimes.py that plots the lifetimes generated by misc/dtrj_lifetimes/compare_dtrj_lifetime_methods.py.

  • Create a new function mdtools.statistics.moment_raw2cen that calculates the n-th central moment from the first n raw moments.

  • Add a new argument uncensored to the functions mdtools.dtrj.lifetimes and mdtools.dtrj.lifetimes_per_state that allows the user to specify whether to discard the states at the beginning and end of the trajectory.

Maintenance

PR checklist

  • I followed the guidelines in the Developer's guide.
  • New/changed code is properly tested.
  • New/changed code is properly documented.
  • The CI workflow is passing.

Create a script that generates an artificial discrete trajectory with a
given number of states with a given lifetime distribution.

This script was written to test different methods to calculate state
lifetimes from discrete trajectories (specifically
`mdtools.dtrj.lifetimes`, `mdtools.dtrj.trans_rate`,
`mdtools.dtrj.remain_prob`).
@github-actions github-actions bot added the maintenance Project maintenance label Jul 20, 2023
New Feature:

* If requested, plot a histogram of the lifetimes drawn from the
  exponential distribution.

Refactoring:

* If the lifetime drawn from the exponential distribution is zero,
  select another state.

* Change dtype of the generated discrete trajectory from `numpy.uint32`
  to `numpy.uint8`.

* Decrease memory footprint by avoiding generating longer trajectories
  than necessary.
Convert number of transitions to `np.int64` to avoid `ZeroDivisionError`
when the total number of transitions is zero and instead return
`np.inf`.
Create a script that compares state lifetimes calculated from a discrete
trajectory using different methods.
Read remain probabilities from a file as created by
`scripts.discretization.state_lifetime_discrete` rather than calculating
them on the fly, because for long discrete trajectories this can take a
long time.
@andthum andthum force-pushed the feat/misc/generate-artificial-discrete-trajectroy branch from b80d5d5 to 5ad4501 Compare July 24, 2023 10:57
Introduce a time conversion factor to convert from "trajectroy steps" to
a physical time unit (like ns).
@andthum andthum force-pushed the feat/misc/generate-artificial-discrete-trajectroy branch 3 times, most recently from 563f8ee to d5a89df Compare July 26, 2023 13:33
Instead of sampling the lifetimes from an exponential distribution,
sample the lifetimes from the more general gamma distribution.
Instead of an exponential distribution assume a more general gamma
distribution for the true lifetimes.
@andthum andthum force-pushed the feat/misc/generate-artificial-discrete-trajectroy branch 2 times, most recently from 37f6392 to f9410a4 Compare July 26, 2023 15:17
Add the command-line option `--param-out` that allows the user to save
the parameters that were used to generate the artificial discrete
trajectory to file.
@andthum andthum force-pushed the feat/misc/generate-artificial-discrete-trajectroy branch from f9410a4 to 9757cb0 Compare July 26, 2023 16:03
@andthum andthum force-pushed the feat/misc/generate-artificial-discrete-trajectroy branch 4 times, most recently from 1aedfbb to f051837 Compare August 2, 2023 12:35
Create a script that plots the PDF, CDF, Survival function and Hazard
function of the generalized gamma distribution for a given set of shape
and scale parameters.
@andthum andthum force-pushed the feat/misc/generate-artificial-discrete-trajectroy branch from b79a1da to e87d895 Compare October 5, 2023 09:19
Instead of calculating the first and second raw moment for each method,
calculate the

* (Sample) mean
* (Corrected sample) standard deviation
* (Unbiased sample) skewness
* (Unbiased sample) excess kurtosis (according to Fisher)
* (Sample) median
Adopt `mdtools/misc/dtrj_lifetimes/plot_lifetimes.py` to the changed
output of
`mdtools/misc/dtrj_lifetimes/compare_dtrj_lifetime_methods.py`.
Add a new command-line option `--adjacent` to the script
`misc/dtrj_lifetimes/generate_dtrj.py` that allows the user to specify
that the next randomly selected state must be a neighbor of the previous
state.
Add example commands to the notes section to generate artificial
trajectories that resemble true discrete trajectories from my work.
Add an example to the notes section for creating a long trajectory that
can be used to generate sub-trajectories that contain only every n-th
frame.
…onv`

Add a new command-line option `--time-conv` that allows the user to
specify a time conversion factor.  All times are multiplied by the given
factor.
@andthum andthum force-pushed the feat/misc/generate-artificial-discrete-trajectroy branch 4 times, most recently from 18ff653 to 99c8e5c Compare October 13, 2023 09:21
Support plotting lifetimes as function of the sampling
interval/frequency of the trajectory.
Add the skewness and kurtosis of the exponential distribution to the
respective plots as reference.
Calculate the uncertainty (standard error) of the sample mean for
count-based methods and write it to the text output file and plot it as
errorbar in the lifetime plot.
Fix explanation of the content of column 52 (end of fit region is
inclusive not exclusive).
Adopt the script `plot_lifetimes.py` to the changes made in the script
`compare_dtrj_lifetime_methods.py`.
Additionally to the log plot of the skewness and kurtosis, plot both
quantities on a linear scale.
…-Dist.

Remove the reference to the skewness and kurtosis of the exponential
distribution in the respective plots, because the skewness and kurtosis
of the true lifetime distribution is already contained in the plot.
Remove the reference to the skewness and kurtosis of the exponential
distribution in the respective plots, because the skewness and kurtosis
of the true lifetime distribution is already contained in the plot.
Update the notes section about generating artificial discrete
trajectories that resemble true discrete trajectories.
@andthum andthum force-pushed the feat/misc/generate-artificial-discrete-trajectroy branch from 99c8e5c to ab551a0 Compare October 13, 2023 13:54
@andthum andthum merged commit dbdc49a into main Oct 13, 2023
17 checks passed
@andthum andthum deleted the feat/misc/generate-artificial-discrete-trajectroy branch October 13, 2023 14:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
maintenance Project maintenance
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant