Skip to content

Frequently Asked Questions

This page contains frequently asked questions about CensoredDistributions.jl. If you have a question that is not answered here, please open a discussion on the GitHub repository.

Working with tutorials

Q: How can I run the tutorial notebooks?

A: You have two options:

Option 1: Copy and paste (easiest)

  • Copy code blocks from the online tutorials

  • Paste into your Julia REPL or script

  • Modify as needed for your analysis

Option 2: Run tutorial scripts directly 2. Clone the repository: git clone https://github.com/EpiAware/CensoredDistributions.jl.git

  1. Start Julia in the repository directory: julia --project=docs

  2. Run a tutorial: include("docs/src/getting-started/tutorials/analytical-primarycensored-cdfs.jl")

The tutorial .jl files are plain Julia scripts that can be run top-to-bottom in the REPL or executed as scripts.

Using the package

Q: How do I create a primary censored distribution?

A: Use the primary_censored function:

julia
using CensoredDistributions, Distributions

# Delay distribution (e.g., incubation period)
delay_dist = Gamma(2, 3)

# Primary event distribution (e.g., infection within a day)
primary_dist = Uniform(0, 1)

# Create censored distribution
censored_dist = primary_censored(delay_dist, primary_dist)
CensoredDistributions.PrimaryCensored{Distributions.Gamma{Float64}, Distributions.Uniform{Float64}, AnalyticalSolver{CensoredDistributions.GaussLegendre{CensoredDistributions._GL{Vector{Float64}, Vector{Float64}}}}}(
dist: Distributions.Gamma{Float64}(α=2.0, θ=3.0)
primary_event: Distributions.Uniform{Float64}(a=0.0, b=1.0)
method: AnalyticalSolver{CensoredDistributions.GaussLegendre{CensoredDistributions._GL{Vector{Float64}, Vector{Float64}}}}(CensoredDistributions.GaussLegendre{CensoredDistributions._GL{Vector{Float64}, Vector{Float64}}}(64, CensoredDistributions._GL{Vector{Float64}, Vector{Float64}}([-0.9993050417357722, -0.9963401167719553, -0.9910133714767443, -0.983336253884626, -0.973326827789911, -0.9610087996520538, -0.9464113748584028, -0.9295691721319396, -0.9105221370785028, -0.8893154459951141  …  0.8893154459951141, 0.9105221370785028, 0.9295691721319396, 0.9464113748584028, 0.9610087996520538, 0.973326827789911, 0.983336253884626, 0.9910133714767443, 0.9963401167719553, 0.9993050417357722], [0.0017832807216964326, 0.004147033260562467, 0.006504457968978363, 0.008846759826363949, 0.011168139460131126, 0.013463047896718644, 0.01572603047602472, 0.01795171577569734, 0.020134823153530212, 0.02227017380838325  …  0.02227017380838325, 0.020134823153530212, 0.01795171577569734, 0.01572603047602472, 0.013463047896718644, 0.011168139460131126, 0.008846759826363949, 0.006504457968978363, 0.004147033260562467, 0.0017832807216964326])))
)

Q: What's the difference between the different types of censoring?

A:

  • Primary event censoring: The timing of the initial event in a delay distribution is uncertain. See the tutorials for detailed examples.

  • Interval censoring: Continuous values are observed only within discrete intervals. See the API documentation for interval_censored.

  • Double interval censoring: Combines both types of censoring. See double_interval_censored in the API documentation.

Q: How do I convolve a censored delay with a timeseries?

A: Loading ConvolvedDistributions.jl alongside CensoredDistributions activates a bridge that lets you pass a regular-grid interval-censored delay straight to convolve_series, which reads the delay's discretised mass function and convolves it with a series sampled on the same grid (e.g. infections to expected observations). The grid width comes from the delay itself, the interval you chose when building it, so the series is interpreted at steps of that width. Use double_interval_censored(dist; interval = w) for the statistically correct interval-binned discretisation of a continuous delay.

julia
using CensoredDistributions, ConvolvedDistributions, Distributions

# Daily grid (interval = 1): series is one value per day.
delay = double_interval_censored(LogNormal(1.5, 0.75); interval = 1)
infections = [0.0, 1.0, 3.0, 6.0, 8.0, 5.0, 2.0]
expected_counts = convolve_series(delay, infections)

# Weekly grid (interval = 7): the same call reads the series per week.
weekly_delay = double_interval_censored(LogNormal(2.5, 0.75); interval = 7)
weekly_expected = convolve_series(weekly_delay, infections)

Q: How do I fit censored distributions to data?

A: See the Fitting with Turing.jl tutorial in the tutorials section for Bayesian inference examples using Turing.jl.

Q: Which distributions have analytical solutions for better performance?

A: See the Analytical CDF Solutions tutorial in the tutorials section for details on which distribution combinations have optimized implementations.

Q: Can I use this with automatic differentiation?

A: Yes. See the Automatic differentiation backends tutorial for a worked example and per-backend timings. The CI badges on the repo README track which backend/scenario pairs currently pass.

Common issues

Q: I get "Package not found" errors

A: Make sure you're in the right environment:

julia
using Pkg
Pkg.activate(".")           # Activate current directory
Pkg.instantiate()           # Install dependencies
Pkg.add("CensoredDistributions")  # Add the package if needed

Q: How do I cite this package?

A: Please cite the GitHub repository and mention the version you used. Citation information for the associated paper will be added when available.

Q: I want to contribute to development

A: See the Developer FAQ and Contributing Guide for development-specific questions and guidelines.

Getting help

Still have questions?