use super::*;
pub fn Ax(config: &MortTableConfig, x: u32, t: u32, entry_age: Option<u32>) -> PolarsResult<f64> {
let new_config = get_new_config_with_selected_table(config, entry_age)?;
let mx = get_value(&new_config, x + t, "Mx")?;
let dx = get_value(&new_config, x, "Dx")?;
Ok(mx / dx)
}
pub fn Ax1n(
config: &MortTableConfig,
x: u32,
n: u32,
t: u32,
entry_age: Option<u32>,
) -> PolarsResult<f64> {
let new_config = get_new_config_with_selected_table(config, entry_age)?;
let mxt = get_value(&new_config, x + t, "Mx")?;
let mxtn = get_value(&new_config, x + t + n, "Mx")?;
let dx = get_value(&new_config, x, "Dx")?;
let result = (mxt - mxtn) / dx;
Ok(result)
}
pub fn nEx(
config: &MortTableConfig,
x: u32,
n: u32,
t: u32,
entry_age: Option<u32>,
) -> PolarsResult<f64> {
let new_config = get_new_config_with_selected_table(config, entry_age)?;
let result = get_value(&new_config, x + t + n, "Dx")? / get_value(&new_config, x, "Dx")?;
Ok(result)
}
pub fn Axn(
config: &MortTableConfig,
x: u32,
n: u32,
t: u32,
entry_age: Option<u32>,
) -> PolarsResult<f64> {
let new_config = get_new_config_with_selected_table(config, entry_age)?;
let result = Ax1n(&new_config, x, n, t, entry_age)? + nEx(&new_config, x, n, t, entry_age)?;
Ok(result)
}
pub fn IAx(config: &MortTableConfig, x: u32, t: u32, entry_age: Option<u32>) -> PolarsResult<f64> {
let new_config = get_new_config_with_selected_table(config, entry_age)?;
let rxt = get_value(&new_config, x + t, "Rx")?;
let dx = get_value(&new_config, x, "Dx")?;
Ok(rxt / dx)
}
pub fn IAx1n(
config: &MortTableConfig,
x: u32,
n: u32,
t: u32,
entry_age: Option<u32>,
) -> PolarsResult<f64> {
let new_config = get_new_config_with_selected_table(config, entry_age)?;
let rxt = get_value(&new_config, x + t, "Rx")?;
let rxtn = get_value(&new_config, x + t + n, "Rx")?;
let dx = get_value(&new_config, x, "Dx")?;
let result = (rxt - rxtn) / dx;
Ok(result)
}
pub fn IAxn(
config: &MortTableConfig,
x: u32,
n: u32,
t: u32,
entry_age: Option<u32>,
) -> PolarsResult<f64> {
let new_config = get_new_config_with_selected_table(config, entry_age)?;
let term = IAx1n(&new_config, x, n, t, entry_age)?;
let pure_endowment = (n as f64) * nEx(&new_config, x, n, t, entry_age)?;
let result = term + pure_endowment;
Ok(result)
}
pub fn DAx1n(
config: &MortTableConfig,
x: u32,
n: u32,
t: u32,
entry_age: Option<u32>,
) -> PolarsResult<f64> {
let new_config = get_new_config_with_selected_table(config, entry_age)?;
let n_a_x1_n = (n + 1) as f64 * Ax1n(&new_config, x, n, t, None)?;
let ia_x1_n = IAx1n(&new_config, x, n, t, None)?;
let result = n_a_x1_n - ia_x1_n;
Ok(result)
}
pub fn DAxn(
config: &MortTableConfig,
x: u32,
n: u32,
t: u32,
entry_age: Option<u32>,
) -> PolarsResult<f64> {
let result = DAx1n(config, x, n, t, entry_age)? + nEx(config, x, n, t, entry_age)?;
Ok(result)
}
pub fn gAx(
config: &MortTableConfig,
x: u32,
g: f64,
t: u32,
entry_age: Option<u32>,
) -> PolarsResult<f64> {
let new_config = get_new_config_with_selected_table(config, entry_age)?;
let adjusted_config = get_new_config_geometric_functions(&new_config, g)?;
let result = Ax(&adjusted_config, x, t, entry_age)?;
Ok(result)
}
pub fn gAx1n(
config: &MortTableConfig,
x: u32,
n: u32,
g: f64,
t: u32,
entry_age: Option<u32>,
) -> PolarsResult<f64> {
let new_config = get_new_config_with_selected_table(config, entry_age)?;
let adjusted_config = get_new_config_geometric_functions(&new_config, g)?;
let result = Ax1n(&adjusted_config, x, n, t, entry_age)?;
Ok(result)
}
pub fn gnEx(
config: &MortTableConfig,
x: u32,
n: u32,
g: f64,
t: u32,
entry_age: Option<u32>,
) -> PolarsResult<f64> {
let new_config = get_new_config_with_selected_table(config, entry_age)?;
let adjusted_config = get_new_config_geometric_functions(&new_config, g)?;
let result = nEx(&adjusted_config, x, n, t, entry_age)?;
Ok(result)
}
pub fn gAxn(
config: &MortTableConfig,
x: u32,
n: u32,
g: f64,
t: u32,
entry_age: Option<u32>,
) -> PolarsResult<f64> {
let term = gAx1n(config, x, n, g, t, entry_age)?;
let pure_endowment = gnEx(config, x, n, g, t, entry_age)?;
let result = term + pure_endowment;
Ok(result)
}