Skip to content

lugriso/Juliaproject_credible-bands-posterior-mean

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

credible-bands-posterior-mean

This project implements and visualizes pointwise credible bands around the posterior mean cumulative distribution function (CDF) under a Dirichlet Process (DP), following the Bayesian non-parametric approach.

A description of the statistical problem, methodology, and theoretical background is provided in the file Problem description.pdf.

Problem overview

The goal is to:

  • compute the posterior mean CDF,
  • generate approximate posterior draws via the Pólya urn scheme,
  • construct pointwise credible bands by taking empirical quantiles at each grid point,
  • visualize how the bands and posterior mean evolve with the sample size and with the concentration parameter (\theta).

Implementation notes (Julia techniques)

The core algorithms are implemented in src/CredibleBandsDP.jl, while all experiments and figures are produced by scripts in the scripts/ folder.

  • API stabilization and types.
    The main routine returns a typed container PointwiseBandsResult{T} rather than an unstructured tuple. This makes the interface explicit (res.grid, res.lower, res.upper, etc.) and improves type stability and readability.

  • Generic programming and multiple dispatch.
    Functions accept generic inputs such as rng::AbstractRNG and grid::AbstractVector{<:Real}. Internally, a simple conversion boundary is used to perform computations in Float64, keeping the implementation robust and numerically stable.

  • Mutating functions and performance patterns.
    Performance-critical routines are written in mutating form (functions ending with !), operate on preallocated arrays, and use @inbounds and view to avoid unnecessary allocations inside hot loops.

  • Reproducibility.
    The project relies on a local Julia environment (Project.toml / Manifest.toml) and deterministic random number generators in the scripts.

Methodological remarks and limitations

  • The constructed credible bands are pointwise credible intervals, not simultaneous credible regions. As discussed in the reference literature, they do not control the global coverage probability and should be interpreted accordingly.

  • No explicit parallelism or systematic benchmarking is implemented. This is a deliberate choice: for the problem sizes considered here, the simulations run in reasonable time on a single core.

Repository structure

  • src/CredibleBandsDP.jl: core DP routines (Pólya urn sampler, ECDF on a grid, posterior mean CDF, pointwise bands).
  • scripts/: scripts to reproduce the figures discussed in the project.
  • Problem description.pdf: detailed explanation of the statistical problem and theory.
  • Project.toml, Manifest.toml: reproducible Julia environment.

How to run

From the repository root:

julia --project=. -e "using Pkg; Pkg.instantiate()"
julia --project=. scripts/Credible_intervals_different_ns.jl

About

Pointwise credible bands for Dirichlet process posterior distributions

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages