Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename UnivDist to Marginal across codebase #369

Merged
merged 1 commit into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed

- The class `UnivDist` has been renamed to `Marginal`. The name more clearly
refers to one-dimensional marginal distributions (of a univariate random
variable), which form a `ProbInput`.
- The property `spatial_dimension` of `ProbInput` and `UQTestFunBareABC` is
renamed to `input_dimension` for clarity (as opposed to `output_dimension`).
- The property `name` of UQ test function instances has been renamed to
Expand Down
30 changes: 15 additions & 15 deletions docs/_toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -136,27 +136,27 @@ parts:
- file: prob-input/probabilistic-input
title: Probabilistic Input Model
- file: prob-input/available
title: Univariate Distributions
title: One-Dimensional Marginal Distributions
sections:
- file: prob-input/univariate-distributions/beta
- file: prob-input/marginal-distributions/beta
title: Beta
- file: prob-input/univariate-distributions/exponential
- file: prob-input/marginal-distributions/exponential
title: Exponential
- file: prob-input/univariate-distributions/gumbel
- file: prob-input/marginal-distributions/gumbel
title: Gumbel (max.)
- file: prob-input/univariate-distributions/logitnormal
- file: prob-input/marginal-distributions/logitnormal
title: Logit-Normal
- file: prob-input/univariate-distributions/lognormal
- file: prob-input/marginal-distributions/lognormal
title: Log-Normal
- file: prob-input/univariate-distributions/normal
- file: prob-input/marginal-distributions/normal
title: Normal (Gaussian)
- file: prob-input/univariate-distributions/triangular
- file: prob-input/marginal-distributions/triangular
title: Triangular
- file: prob-input/univariate-distributions/trunc-gumbel
- file: prob-input/marginal-distributions/trunc-gumbel
title: Truncated Gumbel (max.)
- file: prob-input/univariate-distributions/trunc-normal
- file: prob-input/marginal-distributions/trunc-normal
title: Truncated Normal (Gaussian)
- file: prob-input/univariate-distributions/uniform
- file: prob-input/marginal-distributions/uniform
title: Uniform
- caption: API Reference
chapters:
Expand All @@ -170,8 +170,8 @@ parts:
title: UQTestFun
- file: api/probinput
title: ProbInput
- file: api/univdist
title: UnivDist
- file: api/marginal
title: Marginal
- file: api/input-spec
title: ProbInputSpec
- file: api/funparams
Expand All @@ -188,8 +188,8 @@ parts:
title: Test Function Docs
- file: development/making-a-pull-request
title: Making a Pull Request
- file: development/adding-univariate-distribution
title: Univariate Distribution
- file: development/adding-marginal-distribution
title: Adding a Marginal Distribution
- file: development/about
title: About UQTestFuns
- file: development/code-of-conduct
Expand Down
9 changes: 9 additions & 0 deletions docs/api/marginal.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.. _api_reference_marginal_distribution:

One-Dimensional Marginal Distribution
=====================================

.. automodule:: uqtestfuns.core.prob_input.marginal

.. autoclass:: uqtestfuns.core.prob_input.marginal.Marginal
:members:
15 changes: 7 additions & 8 deletions docs/api/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,13 @@ let's start from the top, the {ref}`built-in test functions <test-functions:avai
represents the input of an uncertainty quantification (UQ) test function.
- An instance of the ``ProbInput`` class consists mainly of the one-dimensional
marginals and a copula specification (not yet supported). Each one-dimensional
marginal comes from a univariate random variable which in turn
is represented by the {ref}`UnivDist <api_reference_univariate_distribution>`
class.
- An instance of class ``UnivDist`` has a (parametric) probability distribution.
Although different instances may have different probability distributions,
they are all instances of the same class.
- As lightweight containers to specify the specifications of a ``ProbInput`` and
a ``UnivDist``, {ref}`three custom <api_reference_input_spec>` ``NamedTuple``
marginal comes is represented
by the {ref}`Marginal <api_reference_marginal_distribution>` class.
- An instance of the ``Marginal`` class has a (parametric) probability
distribution. Although different instances may have different
probability distributions, they are all instances of the same class.
- As lightweight containers to specify the specifications of a ``ProbInput``
and a ``Marginal``, {ref}`three custom <api_reference_input_spec>` ``NamedTuple``
are defined, namely {ref}`api_reference_input_spec_univdist`,
{ref}`api_reference_input_spec_fixdim`, and {ref}`api_reference_input_spec_vardim`.

Expand Down
9 changes: 0 additions & 9 deletions docs/api/univdist.rst

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
(development:adding-univ-dist)=
# Adding a New Univariate Distribution Type
(development:adding-marginal-distribution)=
# Adding a New Marginal Distribution Type

UQTestFuns is delivered with several {ref}`univariate distributions <prob-input:available-univariate-distributions>`
that are used by the currently available test functions.
UQTestFuns is delivered with several one-dimensional
{ref}`marginal distributions <prob-input:available-marginal-distributions>`
(i.e., univariate distributions) that are used by the currently available test functions.
In case a new univariate distribution type is required for a new test function,
the distribution should be added first to the code base.

Expand All @@ -27,12 +28,12 @@ For example:

```python
>>> import uqtestfuns as uqtf
>>> my_var = uqtf.UnivDist(distribution="uniform", parameters=[3, 5])
>>> my_var = uqtf.Marginal(distribution="uniform", parameters=[3, 5])
```

## Step 0: Putting things in the right place

Univariate random variables in UQTestFuns are represented as instances of the `UnivDist` class.
Univariate random variables in UQTestFuns are represented as instances of the `Marginal` class.
The supported distributions for the random variables are implemented in separate modules
located in the `src/uqtestfuns/core/prob_input/univariate_distributions` directory.
Here's how the directory look:
Expand Down Expand Up @@ -361,11 +362,11 @@ SUPPORTED_MARGINALS = {
}
```

This way you can create a new instance of `UnivDist` class by passing the chosen name as the `distribution` and the corresponding parameters:
This way you can create a new instance of `Marginal` class by passing the chosen name as the `distribution` and the corresponding parameters:

```python
>>> import uqtestfuns as uqtf
>>> my_var = uqtf.UnivDist(distribution="uniform", parameters=[3, 5])
>>> my_var = uqtf.Marginal(distribution="uniform", parameters=[3, 5])
```

Remember that the name `uniform` was chosen as the name of this distribution via the module-level variable `DISTRIBUTION_NAME`.
Expand Down
4 changes: 2 additions & 2 deletions docs/development/adding-test-function-implementation.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ Here are some explanations:
(the one-dimensional marginal specification) and `ProbInputSpecFixDim`
(the probabilistic input model). These are lightweight _containers_
(meaning no custom methods) of all the information required to construct,
later on, `UnivDist` and `ProbInput` instances, respectively.
later on, `Marginal` and `ProbInput` instances, respectively.

```{note}
There is also the corresponding `ProbInputSpecVarDim` to store the information
Expand Down Expand Up @@ -221,7 +221,7 @@ The keyword is, by convention, the citation key of the particular reference as l

Also notice that in the code above, we store the specifications of the marginals
in a list of {ref}`api_reference_input_spec_univdist`.
Each element of this list is used to create an instance of `UnivDist`.
Each element of this list is used to create an instance of `Marginal`.

With that, we have completed the input specification of the Branin function.

Expand Down
3 changes: 2 additions & 1 deletion docs/development/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ be sure to check out the guides on:
- {ref}`adding a new test function implementation <development:adding-test-function-implementation>`
- {ref}`adding a new test function documentation <development:adding-test-function-docs>`
- {ref}`making a pull request <development:making-a-pull-request>`
- In case the univariate distribution types are not yet available: {ref}`adding a new univariate distribution <development:adding-univ-dist>`
- In case the univariate distribution types are not yet available:
{ref}`adding a new univariate distribution <development:adding-marginal-distribution>`

## Updating the documentation

Expand Down
4 changes: 2 additions & 2 deletions docs/getting-started/tutorial-custom-functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,8 @@ class and an instance of it can be defined as follows:
```{code-cell} ipython3
# Define a list of marginals
marginals = [
uqtf.UnivDist(distribution="uniform", parameters=[-5, 10], name="x1"),
uqtf.UnivDist(distribution="uniform", parameters=[0, 15], name="x2"),
uqtf.Marginal(distribution="uniform", parameters=[-5, 10], name="x1"),
uqtf.Marginal(distribution="uniform", parameters=[0, 15], name="x2"),
]
# Create a probabilistic input
my_input = uqtf.ProbInput(marginals=marginals, name="Branin-Input")
Expand Down
35 changes: 18 additions & 17 deletions docs/prob-input/available.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
(prob-input:available-univariate-distributions)=
# Available Univariate Distributions
(prob-input:available-marginal-distributions)=
# Available One-Dimensional Marginal Distributions

The table below lists all the available univariate distribution types used
to construct ``UnivDist`` instances. ``UnivDist`` are used to represent the
univariate marginals of a (possibly, multivariate) probabilistic input model.
The table below lists all the available one-dimensional marginal distribution
types used to construct ``Marginal`` instances.
``Marginal`` instances are used to represent the one-dimensional marginals
of a (possibly, multivariate) probabilistic input model.

| Name | Keyword value for `distribution` | Notation | Support | Number of parameters |
|:-------------------------------------------------------------------------------------:|:--------------------------------:|:-------------------------------------------------:|:--------------------------------:|:--------------------:|
| {ref}`Beta <prob-input:univariate-distributions:beta>` | `"beta"` | $\mathrm{Beta}(\alpha, \beta, a, b)$ | $[a, b], \; a, b \in \mathbb{R}$ | 4 |
| {ref}`Exponential <prob-input:univariate-distributions:exponential>` | `"exponential"` | $\mathcal{E}(\lambda)$ | $[0, \infty)$ | 1 |
| {ref}`Gumbel (max.) <prob-input:univariate-distributions:gumbel>` | `"gumbel"` | $\mathrm{Gumbel}(\mu, \beta)$ | $(-\infty, \infty)$ | 2 |
| {ref}`Logit-Normal <prob-input:univariate-distributions:logitnormal>` | `"logitnormal"` | $\mathcal{N}_{\mathrm{logit}}(\mu, \sigma)$ | $(0, 1)$ | 2 |
| {ref}`Log-Normal <prob-input:univariate-distributions:lognormal>` | `"lognormal"` | $\mathcal{N}_{\mathrm{log}} (\mu, \sigma)$ | $(0, \infty)$ | 2 |
| {ref}`Normal (Gaussian) <prob-input:univariate-distributions:normal>` | `"normal"` | $\mathcal{N}(\mu, \sigma)$ | $(-\infty, \infty)$ | 2 |
| {ref}`Triangular <prob-input:univariate-distributions:triangular>` | `"triangular"` | $\mathcal{T}_r(a, b, c)$ | $[a, b], \; a, b \in \mathbb{R}$ | 3 |
| {ref}`Truncated Gumbel (max.) <prob-input:univariate-distributions:trunc-gumbel>` | `"trunc-gumbel"` | $\mathrm{Gumbel}_{\mathrm{Tr}}(\mu, \beta, a, b)$ | $[a, b], \; a, b \in \mathbb{R}$ | 4 |
| {ref}`Truncated Normal (Gaussian) <prob-input:univariate-distributions:trunc-normal>` | `"trunc-normal"` | $\mathcal{N}_{\mathrm{Tr}}(\mu, \sigma, a, b)$ | $[a, b], \; a, b \in \mathbb{R}$ | 4 |
| {ref}`Uniform <prob-input:univariate-distributions:uniform>` | `"uniform"` | $\mathcal{U}(a, b)$ | $[a, b], \; a, b \in \mathbb{R}$ | 2 |
| Name | Keyword value for `distribution` | Notation | Support | Number of parameters |
|:-----------------------------------------------------------------------------------:|:--------------------------------:|:-------------------------------------------------:|:--------------------------------:|:--------------------:|
| {ref}`Beta <prob-input:marginal-distributions:beta>` | `"beta"` | $\mathrm{Beta}(\alpha, \beta, a, b)$ | $[a, b], \; a, b \in \mathbb{R}$ | 4 |
| {ref}`Exponential <prob-input:marginal-distributions:exponential>` | `"exponential"` | $\mathcal{E}(\lambda)$ | $[0, \infty)$ | 1 |
| {ref}`Gumbel (max.) <prob-input:marginal-distributions:gumbel>` | `"gumbel"` | $\mathrm{Gumbel}(\mu, \beta)$ | $(-\infty, \infty)$ | 2 |
| {ref}`Logit-Normal <prob-input:marginal-distributions:logitnormal>` | `"logitnormal"` | $\mathcal{N}_{\mathrm{logit}}(\mu, \sigma)$ | $(0, 1)$ | 2 |
| {ref}`Log-Normal <prob-input:marginal-distributions:lognormal>` | `"lognormal"` | $\mathcal{N}_{\mathrm{log}} (\mu, \sigma)$ | $(0, \infty)$ | 2 |
| {ref}`Normal (Gaussian) <prob-input:marginal-distributions:normal>` | `"normal"` | $\mathcal{N}(\mu, \sigma)$ | $(-\infty, \infty)$ | 2 |
| {ref}`Triangular <prob-input:marginal-distributions:triangular>` | `"triangular"` | $\mathcal{T}_r(a, b, c)$ | $[a, b], \; a, b \in \mathbb{R}$ | 3 |
| {ref}`Truncated Gumbel (max.) <prob-input:marginal-distributions:trunc-gumbel>` | `"trunc-gumbel"` | $\mathrm{Gumbel}_{\mathrm{Tr}}(\mu, \beta, a, b)$ | $[a, b], \; a, b \in \mathbb{R}$ | 4 |
| {ref}`Truncated Normal (Gaussian) <prob-input:marginal-distributions:trunc-normal>` | `"trunc-normal"` | $\mathcal{N}_{\mathrm{Tr}}(\mu, \sigma, a, b)$ | $[a, b], \; a, b \in \mathbb{R}$ | 4 |
| {ref}`Uniform <prob-input:marginal-distributions:uniform>` | `"uniform"` | $\mathcal{U}(a, b)$ | $[a, b], \; a, b \in \mathbb{R}$ | 2 |
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ kernelspec:
name: python3
---

(prob-input:univariate-distributions:beta)=
(prob-input:marginal-distributions:beta)=
# Beta Distribution

The Beta distribution is a four-parameter continuous probability distribution.
Expand Down Expand Up @@ -83,7 +83,7 @@ colors = ["#a6cee3", "#1f78b4", "#b2df8a", "#33a02c"]

univ_dists = []
for parameter in parameters:
univ_dists.append(uqtf.UnivDist(distribution="beta", parameters=parameter))
univ_dists.append(uqtf.Marginal(distribution="beta", parameters=parameter))

fig, axs = plt.subplots(2, 2, figsize=(10,10))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import matplotlib.pyplot as plt
import numpy as np
```

(prob-input:univariate-distributions:exponential)=
(prob-input:marginal-distributions:exponential)=
# Exponential Distribution

The exponential distribution is a single-parameter continuous probability
Expand Down Expand Up @@ -55,7 +55,7 @@ colors = ["#a6cee3", "#1f78b4", "#b2df8a", "#33a02c"]

univ_dists = []
for parameter in parameters:
univ_dists.append(uqtf.UnivDist(distribution="exponential", parameters=parameter))
univ_dists.append(uqtf.Marginal(distribution="exponential", parameters=parameter))

fig, axs = plt.subplots(2, 2, figsize=(10,10))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import matplotlib.pyplot as plt
import numpy as np
```

(prob-input:univariate-distributions:gumbel)=
(prob-input:marginal-distributions:gumbel)=
# Gumbel (max.) Distribution

The Gumbel (max.) distribution is a two-parameter continuous probability distribution.
Expand Down Expand Up @@ -54,7 +54,7 @@ colors = ["#a6cee3", "#1f78b4", "#b2df8a", "#33a02c"]

univ_dists = []
for parameter in parameters:
univ_dists.append(uqtf.UnivDist(distribution="gumbel", parameters=parameter))
univ_dists.append(uqtf.Marginal(distribution="gumbel", parameters=parameter))

fig, axs = plt.subplots(2, 2, figsize=(10,10))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ import matplotlib.pyplot as plt
import numpy as np
```

(prob-input:univariate-distributions:logitnormal)=
(prob-input:marginal-distributions:logitnormal)=
# Logit-Normal Distribution

The logit-normal distribution is a two-parameter continuous probability distribution.
A logit-normal random variable is a variable whose _logit_ is
a {ref}`normally distributed <prob-input:univariate-distributions:normal>`
a {ref}`normally distributed <prob-input:marginal-distributions:normal>`
random variable.

```{admonition} Logit and logistic function
Expand Down Expand Up @@ -85,7 +85,7 @@ colors = ["#a6cee3", "#1f78b4", "#b2df8a", "#33a02c"]
univ_dists = []
for parameter in parameters:
univ_dists.append(
uqtf.UnivDist(distribution="logitnormal", parameters=parameter)
uqtf.Marginal(distribution="logitnormal", parameters=parameter)
)

fig, axs = plt.subplots(2, 2, figsize=(10,10))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ kernelspec:
name: python3
---

(prob-input:univariate-distributions:lognormal)=
(prob-input:marginal-distributions:lognormal)=
# Log-Normal Distribution

The log-normal distribution is a two-parameter continuous probability distribution.
A log-normal random variable is a variable whose (natural) logarithm is
a {ref}`normally distributed <prob-input:univariate-distributions:normal>`
a {ref}`normally distributed <prob-input:marginal-distributions:normal>`
random variable.
The table below summarizes some important aspects of the distribution.

Expand Down Expand Up @@ -60,7 +60,7 @@ colors = ["#a6cee3", "#1f78b4", "#b2df8a", "#33a02c"]
univ_dists = []
for parameter in parameters:
univ_dists.append(
uqtf.UnivDist(distribution="lognormal", parameters=parameter)
uqtf.Marginal(distribution="lognormal", parameters=parameter)
)

fig, axs = plt.subplots(2, 2, figsize=(10,10))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import matplotlib.pyplot as plt
import numpy as np
```

(prob-input:univariate-distributions:normal)=
(prob-input:marginal-distributions:normal)=
# Normal (Gaussian) Distribution

The normal (or Gaussian) distribution is a two-parameter continuous probability
Expand Down Expand Up @@ -66,7 +66,7 @@ colors = ["#a6cee3", "#1f78b4", "#b2df8a", "#33a02c"]

univ_dists = []
for parameter in parameters:
univ_dists.append(uqtf.UnivDist(distribution="normal", parameters=parameter))
univ_dists.append(uqtf.Marginal(distribution="normal", parameters=parameter))

fig, axs = plt.subplots(2, 2, figsize=(10,10))

Expand Down
Loading
Loading