.. _physics-posteriorSampleState: Posterior Sampling State ======================== Class providing the state vector during Bayesian posterior sampling simulations---the current position of a Markov chain in parameter space, together with its chain index, step count, and parameter count. Implementations store and retrieve the parameter vector (via ``get``/``set``), advance the step counter, and optionally maintain a history of chain positions for convergence diagnostics. The state is updated at each MCMC step and queried by the likelihood function to evaluate the model at the proposed parameter values. **Default implementation:** ``posteriorSampleStateSimple`` Methods ------- ``parameterCountSet`` → ``void`` Set the number of active parameters that this state vector will track, allocating internal storage for the parameter vector of the given dimension. * ``integer, intent(in ) :: parameterCount`` ``chainIndex`` → ``integer`` Return the integer index (0-based) of the Markov chain that owns this state object, used to identify chains in multi-chain posterior sampling algorithms. ``chainIndexSet`` → ``void`` Assign the integer chain index to this state object, identifying which Markov chain it belongs to in a multi-chain ensemble sampler. * ``integer, intent(in ) :: chainIndex`` ``count`` → ``integer`` Returns the total number of sampling steps that have been taken since the state was last reset, used for logging and convergence diagnostics. ``dimension`` → ``integer`` Returns the number of active parameters (dimension of the state vector) for this sampling state, equal to the value previously set by ``parameterCountSet``. ``reset`` → ``void`` Reset the state object to its initial condition by zeroing the step counter and clearing any accumulated history, in preparation for a new sampling run. ``get`` → ``double precision, dimension(self%parameterCount)`` Return the current parameter vector representing the position of this chain in the model parameter space at the most recently accepted sampling step. ``update`` → ``void`` Advance the state to the new parameter vector ``stateNew``, optionally logging it to the chain history; ``isConverged`` and ``outlierMask`` are used to track whether post-convergence steps should be recorded. * ``double precision, intent(in ), dimension(:) :: stateNew`` * ``logical , intent(in ) :: logState`` * ``logical , intent(in ) :: isConverged`` * ``logical , intent(in ), dimension(:), optional :: outlierMask`` ``mean`` → ``double precision, dimension(self%parameterCount)`` Return the mean parameter vector computed over all stored steps in the chain history, providing a point estimate of the posterior mode or mean. ``variance`` → ``double precision, dimension(self%parameterCount)`` Return the per-parameter variance computed over all stored steps in the chain history, providing a measure of posterior width for each model parameter. ``acceptanceRate`` → ``double precision`` Return the fraction of proposed moves that were accepted over the recent history of this chain, used to monitor and adaptively tune proposal distributions. ``restore`` → ``void`` Replay a previously recorded state vector into the state history one step at a time, used when resuming a sampling run from a saved log file; ``first`` signals the start of the restoration sequence. * ``double precision, intent(in ), dimension(:) :: stateVector`` * ``logical , intent(in ) :: first`` .. _physics-posteriorSampleStateCorrelation: ``posteriorSampleStateCorrelation`` ----------------------------------- An extension of the ``history`` state, this class also computes and stores the correlation length in each parameter (which is taken to be the median correlation length over all non-outlier chains). **Methods** * ``correlationLength`` — Return the current correlation length in the chains. * ``correlationLengthCompute`` — Compute correlation lengths in the chains. * ``postConvergenceCorrelationCount`` — Return the number of post-convergence correlation lengths that have accrued. **Parameters** * ``[acceptedStateCount]`` (default ``100``) — The number of states to use in acceptance rate statistics. * ``[missingRootHalosAreFatal]`` (default ``.true.``) — If true, if a hosted root halo is not found then a fatal error occurs. Otherwise, such cases are ignored and will not contribute to the halo mass function. * ``[massMinimum]`` — The minimum mass to consider counts. * ``[massMaximum]`` — The maximum mass to consider. * ``[massCountPerDecade]`` — The number of bins per decade of mass. * ``[countBootstraps]`` — The number of bootstrap samples to perform. * ``[description]`` — A description of this mass function. * ``[simulationReference]`` — A reference for the simulation. * ``[simulationURL]`` — A URL for the simulation. .. _physics-posteriorSampleStateHistory: ``posteriorSampleStateHistory`` ------------------------------- An extension of the ``simple`` state, this class also records the mean and variance of each parameter over the history of the simulation. **Methods** * ``operator(+)`` — Addition operator. * ``operator(-)`` — Subtraction operator. * ``operator(/)`` — Division operator. * ``operator(*)`` — Multiplication operator. * ``isZero`` — Returns true if the history is entirely zero. * ``create`` — Creates a history object with a specified range of times. * ``builder`` — Build a history object from an XML definition. * ``dump`` — Dump a history object. * ``dumpRaw`` — Dump a history object in binary. * ``readRaw`` — Read a history object in binary. * ``clone`` — Clone a history object. * ``destroy`` — Destroys a history object. * ``trim`` — Removes any times in a history which have become outdated. * ``trimForward`` — Removes any times in a history *after* the given time. Optionally returns a history object with the removed history. * ``increment`` — Adds two histories, possibly with different time series. * ``interpolatedIncrement`` — Adds two histories, possibly with different time series, by interpolating the second onto the times of the first and adding the interpolated values. * ``extend`` — Extends the time range of a history to encompass the specified limits. * ``reset`` — Resets all entries in a history to zero. * ``setToUnity`` — Set all entries in a history to unity. * ``exists`` — Returns true if the given history has been created. * ``timeSteps`` — Returns an array with the timesteps (i.e. the intervals between successive times) in the given history. * ``serializeCount`` — Return a count of the number of properties in a serialized history object. * ``serialize`` — Serialize a history object to an array. * ``deserialize`` — Deserialize a history object from an array. * ``append`` — Append a history or single instant onto the end of a history. * ``nonStaticSizeOf`` — Returns the size of any non-static components of the type. * ``create`` — Creates a history object with a specified range of times. * ``builder`` — Build a history object from an XML definition. * ``dump`` — Dump a history object. * ``dumpRaw`` — Dump a history object in binary. * ``readRaw`` — Read a history object in binary. * ``clone`` — Clone a history object. * ``destroy`` — Destroys a history object. * ``trim`` — Removes any times in a history which have become outdated. * ``trimForward`` — Removes any times in a history *after* the given time. Optionally returns a history object with the removed history. * ``reset`` — Resets all entries in a history to zero. * ``exists`` — Returns true if the given history has been created. * ``append`` — Append a history or single instant onto the end of a history. * ``nonStaticSizeOf`` — Returns the size of any non-static components of the type. **Parameters** * ``[acceptedStateCount]`` (default ``100``) — The number of states to use in acceptance rate statistics. * ``[timeBegin]`` (default ``0.05d0*ageUniverse``) — The earliest time at which to tabulate the volume averaged history of galaxies (in Gyr). * ``[timeEnd]`` (default ``ageUniverse``) — The latest time at which to tabulate the volume averaged history of galaxies (in Gyr). * ``[historyCount]`` (default ``30``) — The number of steps (spaced logarithmically in cosmic time) at which to tabulate the volume averaged history of galaxies. .. _physics-posteriorSampleStateSimple: ``posteriorSampleStateSimple`` ------------------------------ This class stores the current state but makes no attempt to record a history of the state and so cannot provide measures of the mean or variance of state over the simulation history. It does, however, maintain a running average of the state acceptance rate. The number of steps over which the acceptance rate should be computed is specified by the ``acceptedStateCount``. **(Default implementation)** **Methods** * ``calculationReset`` — Reset memoized calculations. **Parameters** * ``[efficiencyWind]`` (default ``2.2157d-3``) — The coupling efficiency of the black hole accretion-driven wind, defined as the fraction of the accreted rest-mass energy that is deposited as kinetic or thermal energy into the surrounding gas via AGN-driven outflows. * ``[redshiftReionization]`` (default ``9.97d0``) — The redshift of reionization below which baryonic accretion onto halos is suppressed due to the ionizing background heating the intergalactic medium and preventing gas from accreting onto low-mass halos. * ``[opticalDepthReionization]`` — The optical depth to electron scattering below which baryonic accretion is suppressed. * ``[velocitySuppressionReionization]`` (default ``35.0d0``) — The velocity scale below which baryonic accretion is suppressed. * ``[accretionNegativeAllowed]`` (default ``.true.``) — Specifies whether negative accretion (mass loss) is allowed in the simple halo accretion model. * ``[accretionNewGrowthOnly]`` (default ``.false.``) — Specifies whether accretion from the :term:`IGM` is allowed only when a halo is growing past its previous greatest mass. * ``[acceptedStateCount]`` (default ``100``) — The number of states to use in acceptance rate statistics. * ``[timeStepRelative]`` (default ``0.1d0``) — The maximum allowed relative change in time for a single step in the evolution of a node. * ``[timeStepAbsolute]`` (default ``1.0d0``) — The maximum allowed absolute change in time (in Gyr) for a single step in the evolution of a node. * ``[timeStepMinimum]`` (default ``1.0d-6``) — The smallest timestep to use in profiling ODE solver steps. * ``[timeStepMaximum]`` (default ``1.0d+1``) — The largest timestep to use in profiling ODE solver steps. * ``[timeStepPointsPerDecade]`` (default ``3``) — The number of bins per decade of timestep to use when profiling ODE solver steps. * ``[wavelength]`` (default ``1.0d4``) — The wavelength of the photon packet (in \AA). * ``[wavelengthMinimum]`` (default ``0.5d4``) — The minimum wavelength of the photon packet (in \AA). * ``[wavelengthMaximum]`` (default ``2.0d4``) — The maximum wavelength of the photon packet (in \AA). * ``[luminosity]`` (default ``1.0d0``) — The luminosity of the photon packet (in :math:`L_\odot`). * ``[massRatioMajorMerger]`` (default ``0.25d0``) — The mass ratio above which mergers are considered to be "major". * ``[destinationGasMinorMerger]`` (default ``var_str('spheroid')``) — The component to which satellite galaxy gas moves to as a result of a minor merger. * ``[destinationStarsMinorMerger]`` (default ``var_str('spheroid')``) — The component to which satellite galaxy stars move to as a result of a minor merger. * ``[degreesOfFreedom]`` (default ``3.0d0``) — Number of degrees of freedom to assume when computing the energy density of cooling gas in the "simple" cooling time class. * ``[timeScale]`` (default ``1.0d0``) — The timescale (in Gyr) for cooling in the simple cooling rate model. * ``[reionizationRedshift]`` (default ``9.97d0``) — The redshift of reionization in the simple :term:`IGM` state model. * ``[reionizationTemperature]`` (default ``1.0d4``) — The post-reionization temperature (in units of Kelvin) in the simple :term:`IGM` state model. * ``[preReionizationTemperature]`` (default ``10.0d0``) — The pre-reionization temperature (in units of Kelvin) in the simple :term:`IGM` state model. * ``[useFormationHalo]`` (default ``.false.``) — Specifies whether or not the "formation halo" should be used when solving for the radii of galaxies. * ``[solveForInactiveProperties]`` (default ``.true.``) — If true, galactic structure is solved for during evaluation of inactive property integrals. Otherwise, structure is not solved for during this phase---this should only be used if the inactive property integrands *do not* depend on galactic structure. * ``[rateFractionalMaximum]`` (default ``10.0d0``) — The maximum fractional mass loss rate per dynamical time in the simple model of mass loss due to tidal stripping. * ``[beta]`` (default ``1.0d0``) — The scaling factor which multiplies the tidal mass loss rate. * ``[OmegaMatter]`` (default ``0.3153d0``) — The density of matter in the Universe in units of the critical density. * ``[OmegaBaryon]`` (default ``0.04930d0``) — The density of baryons in the Universe in units of the critical density. * ``[OmegaDarkEnergy]`` (default ``0.6847d0``) — The density of dark energy in the Universe in units of the critical density. * ``[temperatureCMB]`` (default ``2.72548d0``) — The present day temperature of the :term:`CMB` in units of Kelvin. * ``[HubbleConstant]`` (default ``67.36d0``) — The present day value of the Hubble parameter in units of km/s/Mpc.