probula
Members list
Type members
Classlikes
Attributes
- Companion
- object
- Supertypes
A distribution from which we can draw samples
A distribution from which we can draw samples
Attributes
- Supertypes
- Known subtypes
A representation of probabilistic models as multivariate distributions, effectively hierarchical Bayesian models.
A representation of probabilistic models as multivariate distributions, effectively hierarchical Bayesian models.
Attributes
A bit of internal DSL magic
A bit of internal DSL magic
Arity-1 convenience extensions live inside the Dist companion so the given is auto-imported (Scala 3 searches companion objects for given instances). The given wrapper makes NotGiven[T <:< Tuple] resolve during given search (not overload resolution, which ignores using constraints).
Overloaded extension methods do compete with trait methods (apparently then the trait methods are tried only) — for this reason even Dist[T] must use extensions, so that we can support other arities.
Arity-1 extensions cannot be simply extensions on Dist[T] because then they also apply to tuples, which have their own extensions.
Attributes
Base trait for Dist[Double] primitives backed by a commons-math AbstractRealDistribution. Subclasses supply two factories: one unbound (for density and CDF queries), one wired to a caller's RNG (for sampling).
Base trait for Dist[Double] primitives backed by a commons-math AbstractRealDistribution. Subclasses supply two factories: one unbound (for density and CDF queries), one wired to a caller's RNG (for sampling).
Attributes
- Supertypes
- Known subtypes
- Self type
An inclusive range of Double values with a fixed step.
An inclusive range of Double values with a fixed step.
Usage:
Doubles(0.0 -> 1.0) by 0.1
Doubles(0.0, 1.0) points 100
50 doubles (0.0 -> 1.0)
Attributes
- Companion
- object
- Supertypes
-
trait IndexedSeq[Double]trait IndexedSeq[Double]trait Equalstrait IterableOnce[Double]class Objecttrait Matchableclass AnyShow all
Attributes
- Companion
- class
- Supertypes
- Self type
-
Exponential.type
A density with a cumulative distribution function. Carries the canonical truncated operation as a default-implemented method, derivable from cdf.
A density with a cumulative distribution function. Carries the canonical truncated operation as a default-implemented method, derivable from cdf.
Composed densities from _flatMap, dep variants, and likelihood stay at HasDensity[T] (no CDF), so the type system blocks truncated on receivers where CDF does not compose cleanly.
Attributes
- Supertypes
- Known subtypes
-
trait DistDclass Exponentialclass Gaussianclass Laplaceclass UniformCclass UniformProbShow all
- Self type
-
Dist[T]
A distribution with a computable unnormalized density function
A distribution with a computable unnormalized density function
Attributes
- Supertypes
- Known subtypes
Representation of Inference Data. The intention is to make it compatible with the inference data in the Python world (one day...)
Laplace (double-exponential) distribution on the real line. Heavier-tailed than Gaussian, with a sharp peak at mean. scale is the canonical Laplace scale parameter b — not the standard deviation (Laplace stdDev = √2·scale).
Laplace (double-exponential) distribution on the real line. Heavier-tailed than Gaussian, with a sharp peak at mean. scale is the canonical Laplace scale parameter b — not the standard deviation (Laplace stdDev = √2·scale).
Attributes
- Companion
- object
- Supertypes
A link function for a GLM: a monotone bijection between the mean scale (a probability) and the linear-predictor scale (the real line).
A link function for a GLM: a monotone bijection between the mean scale (a probability) and the linear-predictor scale (the real line).
Implementations must satisfy, up to floating-point error: inverse(apply(μ)) == μ for μ in (0, 1) apply(inverse(η)) == η for finite η
The endpoints map to ±∞ and do not round-trip.
Attributes
- Supertypes
- Known subtypes
Attributes
- Supertypes
-
trait Enumtrait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
Witness that all components of T can be decomposed into Doubles. Works for bare numeric scalars (via Numeric) and tuples of numerics (recursively).
Witness that all components of T can be decomposed into Doubles. Works for bare numeric scalars (via Numeric) and tuples of numerics (recursively).
Attributes
- Companion
- object
- Supertypes
- Known subtypes
Attributes
- Companion
- trait
- Supertypes
- Self type
-
NumericDecomposition.type
The Probula object is used as an entry point to the framework. One starts building a probula probabilistic model by using factory methods from this object. Once the model is initiated (the first variable is created), one can use the model methods (@see probula.Dist) to add more new variables, hierarchical dependencies, and observations.
The Probula object is used as an entry point to the framework. One starts building a probula probabilistic model by using factory methods from this object. Once the model is initiated (the first variable is created), one can use the model methods (@see probula.Dist) to add more new variables, hierarchical dependencies, and observations.
Attributes
- Supertypes
- Self type
-
Probula.type
The TupleModel trait is used to hide the model structure for typed functional programming (for instance if the internal type is a tuple, and the shape is manipulated in an iteration, like a fold)
The TupleModel trait is used to hide the model structure for typed functional programming (for instance if the internal type is a tuple, and the shape is manipulated in an iteration, like a fold)
Value parameters
- H
-
The type of the first component of the model
- L
-
The type of the last (most recently appended) component of the model
Attributes
- Companion
- object
- Supertypes
Attributes
- Companion
- trait
- Supertypes
- Self type
-
TupleModel.type
A UniformC(0.0, 1.0) retyped as Dist[Prob]. Lets a model's probability parameters stay in the Prob opaque type rather than being lifted from Double at every use.
A UniformC(0.0, 1.0) retyped as Dist[Prob]. Lets a model's probability parameters stay in the Prob opaque type rather than being lifted from Double at every use.
Attributes
- Companion
- object
- Supertypes
Attributes
- Companion
- class
- Supertypes
- Self type
-
UniformProb.type
Types
Commons-Math-flavoured view of RNG. Distributions that delegate to commons-math samplers consume this type.
Value members
Concrete methods
Extensions
Extensions
Export inference data as a CSV string. Columns: sample, one per variable, log_weight. Variable names are derived from this IData's Name.
Export inference data as a CSV string. Columns: sample, one per variable, log_weight. Variable names are derived from this IData's Name.
Attributes
Same as mean.
Same as mean.
Attributes
Compute a mean for a numeric sample. A numerically stable way to compute this, similar to LogSumExp, but exploiting that max cancels out in the numerator and denominator.
Compute a mean for a numeric sample. A numerically stable way to compute this, similar to LogSumExp, but exploiting that max cancels out in the numerator and denominator.
Attributes
Compute a median of a sample with a defined Ordering.
Compute a median of a sample with a defined Ordering.
For simplicity we drop one element if the sample is of even length. Typically to be used on a univariate sample of numbers (then the ordering exists).
It requires that the chain is finite! Otherwise it will crash.
Attributes
Compute a weighted percentile for a numeric sample. Returns the value below which fraction q of the weighted mass falls. Linearly interpolates between the two bracketing values when the threshold falls between samples.
Compute a weighted percentile for a numeric sample. Returns the value below which fraction q of the weighted mass falls. Linearly interpolates between the two bracketing values when the threshold falls between samples.
Uses the same weighted cumulative mass approach as median, generalized to an arbitrary threshold.
Value parameters
- q
-
the quantile in [0, 1] (e.g. 0.5 for the median, 0.055 for the 5.5th percentile)
Attributes
Compute the standard deviation for a numeric sample. This is the square root of the variance.
Compute the standard deviation for a numeric sample. This is the square root of the variance.
Attributes
Compute a sample variance for a numeric sample. Uses the unbiased weighted estimator (a generalization of Bessel's correction for weighted samples, for example see reliability weights in https://en.wikipedia.org/wiki/Weighted_arithmetic_mean #Related_concepts): Var = sum wi(xi - mu)^2 * V1 / (V1^2 - V2) where V1 = sum wi, V2 = sum wi^2. For uniform weights this reduces to sum(xi - mu)^2/(n-1). Uses the max-subtraction trick (as in mean) for numerical stability when log-scores are very negative.
Compute a sample variance for a numeric sample. Uses the unbiased weighted estimator (a generalization of Bessel's correction for weighted samples, for example see reliability weights in https://en.wikipedia.org/wiki/Weighted_arithmetic_mean #Related_concepts): Var = sum wi(xi - mu)^2 * V1 / (V1^2 - V2) where V1 = sum wi, V2 = sum wi^2. For uniform weights this reduces to sum(xi - mu)^2/(n-1). Uses the max-subtraction trick (as in mean) for numerical stability when log-scores are very negative.
Attributes
The plate members are named name0...nameN, where N = self.size - 1. The list node is named name.
The plate members are named name0...nameN, where N = self.size - 1. The list node is named name.
Attributes
The plate members are named name0...nameN, where N = self.size - 1. The list node is named name.
The plate members are named name0...nameN, where N = self.size - 1. The list node is named name.
Attributes
Neither the plate or its members are named.
Neither the plate or its members are named.
Attributes
You need to name your plate members yourself. Name name is given to the overall Dist[Seq[U]] node
You need to name your plate members yourself. Name name is given to the overall Dist[Seq[U]] node
Attributes
You need to name your plate members yourself. Name name is given to the overall Dist[Seq[U]] node
You need to name your plate members yourself. Name name is given to the overall Dist[Seq[U]] node
Attributes
You need to name your plate members yourself. The overall node is not named.
You need to name your plate members yourself. The overall node is not named.
Attributes
The plate members are named name0...nameN, where N = self.size - 1. The list node is named name.
The plate members are named name0...nameN, where N = self.size - 1. The list node is named name.
Attributes
The plate members are named name0...nameN, where N = self.size - 1. The list node is named name.
The plate members are named name0...nameN, where N = self.size - 1. The list node is named name.
Attributes
Neither the plate or its members are named.
Neither the plate or its members are named.
Attributes
You need to name your plate members yourself. Name name is given to the overall Dist[Seq[U]] node
You need to name your plate members yourself. Name name is given to the overall Dist[Seq[U]] node
Attributes
You need to name your plate members yourself. Name name is given to the overall Dist[Seq[U]] node
You need to name your plate members yourself. Name name is given to the overall Dist[Seq[U]] node
Attributes
You need to name your plate members yourself. The overall node is not named.
You need to name your plate members yourself. The overall node is not named.
Attributes
Unfortunately, these methods cannot be called traverse/plate, etc., as resolution based on argument's return type is very brittle. Does not work if they are in the same type hierarchy Dist[U] & HasDensity[U] <: Dist[U]. We get a conflict with the non-density traverse.
Unfortunately, these methods cannot be called traverse/plate, etc., as resolution based on argument's return type is very brittle. Does not work if they are in the same type hierarchy Dist[U] & HasDensity[U] <: Dist[U]. We get a conflict with the non-density traverse.
Attributes
Same as mean.
Same as mean.
Attributes
Delegator to Chain.percentile.
Delegator to Chain.percentile.
Attributes
Delegator to Chain.stdDev.
Delegator to Chain.stdDev.
Attributes
A summary table of the posterior, showing mean, standard deviation, the 89% percentile interval (5.5% to 94.5%), and a sparkline histogram for each variable. Inspired by McElreath's precis.
A summary table of the posterior, showing mean, standard deviation, the 89% percentile interval (5.5% to 94.5%), and a sparkline histogram for each variable. Inspired by McElreath's precis.
Value parameters
- histogram
-
whether to include a sparkline histogram column (default: true)
Attributes
Clamps to [lo, hi]: returns lo below the range, hi above it.
Clamps to [lo, hi]: returns lo below the range, hi above it.