Skip to content

Commit

Permalink
Update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
jzsmoreno committed Jan 31, 2024
1 parent 8f118e3 commit 2844297
Show file tree
Hide file tree
Showing 6 changed files with 107 additions and 116 deletions.
3 changes: 0 additions & 3 deletions likelihood/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
"""
Authors: J. A. Moreno-Guerra & J. I. Ávalos-López
Library version: 1.2.0
Last modification: 29/10/2023
Corresponding author: [email protected]
"""

Expand Down
84 changes: 41 additions & 43 deletions likelihood/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import corner
import matplotlib.pyplot as plt
import numba
import numpy as np
from numpy import ndarray

Expand All @@ -12,15 +11,15 @@ def lnprior(theta: ndarray, conditions: List[Tuple[float, float]]) -> float:
Parameters
----------
theta : np.ndarray
theta : `np.ndarray`
An array containing the parameters of the model.
conditions : list
conditions : `list`
A list containing $2n$-conditions for the (min, max) range of the
$n$ parameters.
Returns
-------
lp : float
lp : `float`
The a priori probability.
"""

Expand Down Expand Up @@ -53,24 +52,24 @@ def fun_like(
Parameters
----------
x : np.ndarray
x : `np.ndarray`
An $(m, n)$ dimensional array for (cols, rows).
y : np.ndarray
y : `np.ndarray`
An $n$ dimensional array that will be compared with model's output.
model : function
model : `Callable`
A Python function defined by the user. This function should recieve
two arguments $(x, theta)$.
theta : np.ndarray
two arguments $(`x`, `theta`)$.
theta : `np.ndarray`
The array containing the model's parameters.
conditions : list
conditions : `list`
A list containing $2n$-conditions for the (min, max) range of the
$n$ parameters.
var2 : float
var2 : `float`
Determines the step size of the walker. By default it is set to `1.0`.
Returns
-------
lhood : float
lhood : `float`
The computed likelihood.
"""

Expand All @@ -94,20 +93,19 @@ def fun_like(
return lhood


@numba.jit(nopython=True)
def update_theta(theta: ndarray, d: float) -> ndarray:
"""Updates the theta parameters.
Parameters
----------
theta : np.ndarray
theta : `np.ndarray`
The ndarray containing the model's parameters.
d : float
d : `float`
Size of the Gaussian step for the walker.
Returns
-------
theta_new : np.array
theta_new : `np.array`
An ndarray with the updated theta values.
"""

Expand All @@ -132,38 +130,38 @@ def walk(
Parameters
----------
x : np.ndarray
x : `np.ndarray`
An $(m, n)$ dimensional array for (cols, rows).
y : np.ndarray
An $n$ dimensional array that will be compared with model's output.
model : function
model : `Callable`
A Python function defined by the user. This function should recieve
two arguments $(x, theta)$.
theta : np.ndarray
theta : `np.ndarray`
The array containing the model's parameters.
conditions : list
conditions : `list`
A list containing $2n$-conditions for the (min, max) range of the
$n$ parameters.
var2 : float
var2 : `float`
Determines the step size of the walker. By default it is set to `1.0`.
mov : int
mov : `int`
Number of movements that walker will perform. By default it is set
to `100`.
d : float
d : `float`
Size of the Gaussian step for the walker.
tol : float
Convergence criteria for the log-likelihhod. By default it is set
tol : `float`
Convergence criteria for the log-likelihood. By default it is set
to `1e-3`.
mode : bool
mode : `bool`
By default it is set to `True`.
Returns
-------
theta : np.array
theta : `np.array`
An ndarray with the updated theta values.
nwalk : np.array
nwalk : `np.array`
Updates of theta for each movement performed by the walker.
y0 : float
y0 : `float`
The log-likelihood value.
"""

Expand Down Expand Up @@ -228,42 +226,42 @@ def walkers(
Parameters
----------
nwalkers : int
nwalkers : `int`
The number of walkers to be executed.
x : np.ndarray
x : `np.ndarray`
An $(m, n)$ dimensional array for (cols, rows).
y : np.ndarray
y : `np.ndarray`
An $n$ dimensional array that will be compared with model's output.
model : function
model : `Callable`
A Python function defined by the user. This function should recieve
two arguments $(x, theta)$.
theta : np.ndarray
theta : `np.ndarray`
The array containing the model's parameters.
conditions : list
conditions : `list`
A list containing $2n$-conditions for the (min, max) range of the
$n$ parameters.
var2 : float
var2 : `float`
Determines the step size of the walker. By default it is set to `1.0`.
mov : int
mov : `int`
Number of movements that walker will perform. By default it is set
to `100`.
d : float
d : `float`
Size of the Gaussian step for the walker.
tol : float
tol : `float`
Convergence criteria for the log-likelihhod. By default it is set
to `1e-3`.
mode : bool
mode : `bool`
Specifies that we will be working with more than one walker. By
default it is set to `False`.
figname : str
figname : `str`
The name of the output file for the figure. By default it is set
to `fig_out.png`.
Returns
-------
par : np.array
par : `np.array`
The theta found by each of the walkers.
error : np.array
error : `np.array`
The log-likelihood array.
"""

Expand Down
18 changes: 9 additions & 9 deletions likelihood/tools/numeric_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,20 +42,20 @@ def sor_elimination(A, b, n, nmax, w):
Parameters
----------
A : np.array
A : `np.array`
An array containing the parameters of the $n$ equations.
b : np.array
b : `np.array`
An array containing the equalities of the $n$ equations.
n : int
n : `int`
Is the dimension of the system of equations.
nmax : int
nmax : `int`
Is the maximum number of iterations.
w : float
w : `float`
Is a parameter of the SOR method
Returns
-------
xi : np.array
xi : `np.array`
The solution of the system of $n$ equations
"""

Expand Down Expand Up @@ -86,16 +86,16 @@ def gauss_elimination(A, pr=2):
Parameters
----------
A : np.array or list
A : `np.array` or `list`
An array containing the parameters of the $n$ equations
with the equalities.
pr : int
pr : `int`
significant numbers of decimals.
Returns
-------
X : np.array
X : `np.array`
The solution of the system of $n$ equations
"""
Expand Down
Loading

0 comments on commit 2844297

Please sign in to comment.