Metadata-Version: 2.4
Name: decision_methods
Version: 0.1.0
Summary: Library for decision threshold and boundary methods
Author-email: Jose Francisco Benavente Cuevas <jf.benavente@ciemat.es>, Jose Antonio Suarez Navarro <ja.suarez@ciemat.es>, Victor Manuel Exposito Suarez <VictorManuel.Exposito@ciemat.es>
License: MIT
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: numpy>=1.20
Requires-Dist: matplotlib>=3.5
Requires-Dist: scipy
Dynamic: license-file

# 🚀 decision_methods

**A scientific Python library for computing decision thresholds and limits using numerical methods independent of the analytical expression.**

Includes advanced implementations such as:
- **UD** — Decision Threshold  
- **LID** — Decision Limit  

---

## ✨ Key Features

- Numerical methods applicable to **any analytical model**
- Full **uncertainty propagation**
- Robust **root-finding algorithms**
- Scientific computation ready for real-world data
- Visualization tools for LID analysis

---

## ⚙️ Core Function

### 🔹 `compute_F_ud_lid`

Computes:

- Model value  
- Associated uncertainty  
- Decision Threshold (**UD**)  
- Decision Limit (**LID**)  

#### **Parameters**

- `p` *(array-like)* — Model parameter vector  
- `t_m` *(float)* — Measurement time  
- `t_f` *(float)* — Background time  
- `f` *(callable)* — Multivariable function  
- `pderivative` *(callable)* — Partial derivative function  
- `bisection` *(callable)* — Root-finding method  
- `k` *(float, optional)* — Coverage factor *(default: 1.65)*  
- `LID_a` *(float)* — Lower bound for LID search  
- `LID_b` *(float)* — Upper bound for LID search  
- `cpm_min`*(float)* — Lower bound of the count rate (counts per unit time, e.g., minutes or seconds; CPM) used in the LID search
- `cpm_max`*(float)* — Upper bound of the count rate (counts per unit time, e.g., minutes or seconds; CPM) used in the LID search
- `cpm_index`*(integer)* — Index of the parameter corresponding to the count rate (CPM) used in the LID search 
- `sample_indices` *(tuple of int, optional)* — Indices of parameters corresponding to sample measurements modeled as Poisson-distributed variables, with expected counts defined as the parameter value scaled by the measurement time t_m *(default: (0,))*  
- `background_indices` *(tuple of int, optional)* — Indices of parameters corresponding to sample measurements modeled as Poisson-distributed variables, with expected counts defined as the parameter value scaled by the measurement time t_f *(default: (1,))*   
- `rel_map` *(tuple of (int, float), optional)* — Relative uncertainty definitions as *(index, relative_error)* pairs  
- `frac_fondo` *(float, optional)* — Relative uncertainty for background when `t_f <= 0`  

#### **Returns**

- `value` *(float)* — Evaluated value of the model function  
- `u_value` *(float)* — Combined uncertainty  
- `UD` *(float)* — Decision threshold  
- `LID` *(float)* — Decision limit  
#### **Returns**

- `value` *(float)* — Evaluated value of the model function  
- `u_value` *(float)* — Combined uncertainty  
- `UD` *(float)* — Decision threshold  
- `LID` *(float)* — Decision limit  

---

## 📊 Visualization

### 🔹 `plot_lid_function`

Generates plots to analyze LID behavior.

#### **Parameters**

- `LID_a` *(float)* — Lower bound  
- `LID_b` *(float)* — Upper bound  
- `p` *(array-like)* — Parameters  
- `f` *(callable)* — Function  
- `UD` *(float)* — Decision threshold  
- `t_m` *(float)* — Measurement time  
- `t_f` *(float)* — Background time  
- `pderivative` *(callable)* — Partial derivative function  
- `bisection` *(callable)* — Root-finding method  
- `cpm_min`*(float)* — Lower bound of the count rate (counts per unit time, e.g., minutes or seconds; CPM) used in the LID search
- `cpm_max`*(float)* — Upper bound of the count rate (counts per unit time, e.g., minutes or seconds; CPM) used in the LID search
- `n`*(integer)* — Number of samples or observations used in the LID search
- `cpm_index`*(integer)* — Index of the parameter corresponding to the count rate (CPM) used in the LID search 
- `k` *(float, optional)* — Coverage factor *(default: 1.65)*  
- `rel_map` *(tuple of (int, float), optional)* — Relative uncertainty definitions as *(index, relative_error)* pairs  

---

## 🧪 Activity Functions

### 🔹 `AT` — Total Alpha

Computes total alpha activity.

$AT(Bq\cdot m^{3})= \frac{CPM_M-CPM_F}{60 \cdot ɛ \cdot V_{Alicuot}}$

#### **Parameters**

- `CPM_m` *(float)* — Sample counts  
- `CPM_f` *(float)* — Background counts  
- `Eps` *(float)* — Detection efficiency  
- `V_ali` *(float)* — Aliquot volume  

#### **Returns**

- *(float)* — Activity  

---

### 🔹 `BT` — Total Beta

Computes total beta activity.

$BT(Bq\cdot m^{3})= \frac{CPM_{\beta-M}-CPM_{\beta-F} - γ \cdot(CPM_{α-M}-CPM_{α-F})}{60 \cdot Ef_{Sr} \cdot V_{Alicuot}⋅Fa}$

#### **Parameters**

- `CPM_b_m` *(float)* — Measured beta counts  
- `CPM_b_f` *(float)* — Background beta counts  
- `CPM_a_m` *(float)* — Measured alpha counts  
- `CPM_a_f` *(float)* — Background alpha counts  
- `Spill` *(float)* — Spillover correction factor  
- `EFSr` *(float)* — Detection efficiency factor  
- `Fa` *(float)* — Correction factor  
- `V_ali` *(float)* — Aliquot volume  

#### **Returns**

- *(float)* — Total beta activity  

---

## 📦 Installation

```bash
pip install decision_methods
