-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add support for volatility coupling with input nodes
- Loading branch information
1 parent
0aa0e6a
commit 1cbc780
Showing
12 changed files
with
1,735 additions
and
156 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
1,204 changes: 1,204 additions & 0 deletions
1,204
docs/source/notebooks/Example_2_Input_node_volatility_coupling.ipynb
Large diffs are not rendered by default.
Oops, something went wrong.
71 changes: 71 additions & 0 deletions
71
docs/source/notebooks/Example_2_Input_node_volatility_coupling.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
--- | ||
jupytext: | ||
formats: ipynb,md:myst | ||
text_representation: | ||
extension: .md | ||
format_name: myst | ||
format_version: 0.13 | ||
jupytext_version: 1.15.1 | ||
kernelspec: | ||
display_name: Python 3 (ipykernel) | ||
language: python | ||
name: python3 | ||
--- | ||
|
||
(example_1)= | ||
# Example 2: Volatility coupling with an input node | ||
|
||
```{code-cell} ipython3 | ||
%%capture | ||
import sys | ||
if 'google.colab' in sys.modules: | ||
! pip install pyhgf | ||
``` | ||
|
||
```{code-cell} ipython3 | ||
from pyhgf.distribution import HGFDistribution | ||
from pyhgf.model import HGF | ||
import numpy as np | ||
import pymc as pm | ||
import arviz as az | ||
import matplotlib.pyplot as plt | ||
import seaborn as sns | ||
``` | ||
|
||
Where the standard continuous HGF assumes a known precision in the input node (usually set to something high), this assumption can be relaxed and the filter can also try to estimate this quantity from the data. | ||
|
||
```{code-cell} ipython3 | ||
input_data = np.random.normal(size=1000) | ||
``` | ||
|
||
```{code-cell} ipython3 | ||
jget_hgf = ( | ||
HGF(model_type=None) | ||
.add_input_node(kind="continuous") | ||
.add_value_parent(children_idxs=[0]) | ||
.add_volatility_parent(children_idxs=[0]) | ||
.add_volatility_parent(children_idxs=[1]) | ||
.init() | ||
) | ||
jget_hgf.plot_network() | ||
``` | ||
|
||
```{code-cell} ipython3 | ||
jget_hgf.attributes | ||
``` | ||
|
||
```{code-cell} ipython3 | ||
jget_hgf.input_data(input_data[:30]) | ||
``` | ||
|
||
```{code-cell} ipython3 | ||
jget_hgf.plot_trajectories() | ||
``` | ||
|
||
```{code-cell} ipython3 | ||
jget_hgf.to_pandas() | ||
``` | ||
|
||
```{code-cell} ipython3 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Oops, something went wrong.