gam_models/gamlss/gaussian/
binomial_locscale_decl.rs1use super::*;
6
7#[derive(Clone)]
8pub struct BinomialLocationScaleFamily {
9 pub y: Array1<f64>,
10 pub weights: Array1<f64>,
11 pub link_kind: InverseLink,
12 pub threshold_design: Option<DesignMatrix>,
13 pub log_sigma_design: Option<DesignMatrix>,
14 pub policy: gam_runtime::resource::ResourcePolicy,
19}
20
21macro_rules! impl_binomial_location_scale_joint_psi_family {
28 ($family:ty, $label:literal) => {
29 impl LocationScaleJointPsiFamily for $family {
30 type Direction = LocationScaleJointPsiDirection;
31 const LABEL: &'static str = $label;
32
33 fn ws_policy(&self) -> &gam_runtime::resource::ResourcePolicy {
34 &self.policy
35 }
36
37 fn ws_exact_joint_dense_block_designs<'a>(
38 &'a self,
39 specs: Option<&'a [ParameterBlockSpec]>,
40 ) -> Result<Option<(Cow<'a, Array2<f64>>, Cow<'a, Array2<f64>>)>, String> {
41 self.exact_joint_dense_block_designs(specs)
42 }
43
44 fn ws_psi_direction(
45 &self,
46 block_states: &[ParameterBlockState],
47 derivative_blocks: &[Vec<crate::custom_family::CustomFamilyBlockPsiDerivative>],
48 psi_index: usize,
49 design_loc: &Array2<f64>,
50 design_scale: &Array2<f64>,
51 policy: &gam_runtime::resource::ResourcePolicy,
52 ) -> Result<Option<LocationScaleJointPsiDirection>, String> {
53 self.exact_newton_joint_psi_direction(
54 block_states,
55 derivative_blocks,
56 psi_index,
57 design_loc,
58 design_scale,
59 policy,
60 )
61 }
62
63 fn ws_psi_second_order_terms_from_parts(
64 &self,
65 block_states: &[ParameterBlockState],
66 derivative_blocks: &[Vec<crate::custom_family::CustomFamilyBlockPsiDerivative>],
67 psi_a: &LocationScaleJointPsiDirection,
68 psi_b: &LocationScaleJointPsiDirection,
69 design_loc: &Array2<f64>,
70 design_scale: &Array2<f64>,
71 subsample: Option<&[crate::outer_subsample::WeightedOuterRow]>,
72 ) -> Result<ExactNewtonJointPsiSecondOrderTerms, String> {
73 assert!(subsample.is_none());
74 self.exact_newton_joint_psisecond_order_terms_from_parts(
75 block_states,
76 derivative_blocks,
77 psi_a,
78 psi_b,
79 design_loc,
80 design_scale,
81 )
82 }
83
84 fn ws_psi_hessian_directional_from_parts(
85 &self,
86 block_states: &[ParameterBlockState],
87 psi_dir: &LocationScaleJointPsiDirection,
88 d_beta_flat: &Array1<f64>,
89 design_loc: &Array2<f64>,
90 design_scale: &Array2<f64>,
91 subsample: Option<&[crate::outer_subsample::WeightedOuterRow]>,
92 ) -> Result<Array2<f64>, String> {
93 assert!(subsample.is_none());
94 self.exact_newton_joint_psihessian_directional_derivative_from_parts(
95 block_states,
96 psi_dir,
97 d_beta_flat,
98 design_loc,
99 design_scale,
100 )
101 }
102 }
103 };
104}
105
106impl_binomial_location_scale_joint_psi_family!(
107 BinomialLocationScaleFamily,
108 "BinomialLocationScaleFamily"
109);
110
111impl_binomial_location_scale_joint_psi_family!(
112 BinomialLocationScaleWiggleFamily,
113 "BinomialLocationScaleWiggleFamily"
114);
115
116pub(crate) type BinomialLocationScaleExactNewtonJointPsiWorkspace =
117 LocationScaleJointPsiWorkspace<BinomialLocationScaleFamily>;
118
119pub(crate) type BinomialLocationScaleWiggleExactNewtonJointPsiWorkspace =
120 LocationScaleJointPsiWorkspace<BinomialLocationScaleWiggleFamily>;