HABQT-0.1.0.0: Hierarchical adaptive Bayesian quantum tomography for quantum bits

Safe HaskellNone
LanguageHaskell2010

HABQTlib.Data.Particle

Description

Data structures and functions that deal with storing and processing particle hierarchies.

Warning: functions in this module assume that the ptsParticles is non-empty and NumberOfParticles, Dim, and Rank are positive, no validation is performed. If you use them directly, instead of employing API from HABQTlib, you must ensure those assumptions hold.

Synopsis

Documentation

data Particles Source #

A vector of weighed density matrices is stored along with their rank and number. ptsWeight corresponds to the collective weight of particles of rank ptsRank in the hierarchical model, it is not the sum of individual weights of particles (that is normalised to unity after every update).

genParticles :: Dim -> Rank -> NumberOfParticles -> IO Particles Source #

Generates random particles (according to induced measure).

updateParticles :: PureStateVector -> Particles -> Particles Source #

Given a measurement result, perform a Bayesian update over the particles.

type ParticleHierarchy = Vector Particles Source #

Particle hierarchy is described by a vector of Particles.

initialiseParticleHierarchy :: Dim -> NumberOfParticles -> IO ParticleHierarchy Source #

Helper function that generates random particles of each applicable rank.

updateParticleHierarchy :: PureStateVector -> ParticleHierarchy -> ParticleHierarchy Source #

Given a measurement result, update all particles, then normalise resulting hierarchical weights to sum to unity.

getMixedEstimate :: ParticleHierarchy -> DensityMatrix Source #

Summarise the whole particle hierarchy into one mean Bayesian estimate.

foldOverPts Source #

Arguments

:: (DensityMatrix -> a)

function to map over density matrices

-> (Weight -> a -> b)

function to combine weights with results of mapping

-> (c -> b -> c)

fold funciton

-> c

seed value for folding

-> Particles 
-> c 

Map density matrices, combine them with their weights, and then perform a (strict left) fold of results.

reduceParticlesToMean :: Particles -> WeighedDensityMatrix Source #

Summarise particles to a mean estimate (weighed by the corresponding hierarchical weight of the rank).

effectiveSize :: Particles -> Double Source #

Calculate the effective sample size of particles (weights don’t necessarily have to be normalised).

data ResampleArgs Source #

Arguments for the resampling function.

Constructors

ResampleArgs 

resampleMultinom :: GenIO -> Particles -> IO Particles Source #

Multinomial resampling of particle vector, which equalises weights of particles.

resample :: ResampleArgs -> [PureStateVector] -> Particles -> IO Particles Source #

Resample particles. First does one multinomial step that equalises the weights, then performs MHMC iterations adaptively refining the proposal distribution based on acceptance rate. argMinIter iterations are performed for proposal distributions with significant acceptance rates.

ecdf :: Vector WeighedDensityMatrix -> Vector Double Source #

Calculates values of empirical distribution function at data points.

icdf :: Vector Double -> Double -> Int Source #

O(log n) Given a non-empty sorted vector (typically an empirical cdf evaluated at data points returned by ecdf) and a real number return the (0-based) index of the least element of vector which is greater or equal to the given real number (or the index of the last element, in case there is no element smaller than the argument).

nudgeParticle Source #

Arguments

:: Dim 
-> Weight

Relative weight (from 0 to 1) of random component

-> WeighedDensityMatrix 
-> IO WeighedDensityMatrix 

Nudges a particle by mixing the state together with some randomly generated pure state. Relative weight of the random component determines how “close” a nudged particle is to the original one.