@@ -184,44 +184,25 @@ def __init__(
184
184
185
185
self .h_kappa = _check .pos_float (h_kappa ,'h_kappa' ,ParameterFormatError )
186
186
self .rng = np .random .default_rng (seed )
187
- self ._H_PARAM_KEYS = {'h_m_vec' ,'h_kappa' ,'h_nu' ,'h_w_mat' }
188
- self ._H0_PARAM_KEYS = {'h0_m_vec' ,'h0_kappa' ,'h0_nu' ,'h0_w_mat' }
189
- self ._HN_PARAM_KEYS = {'hn_m_vec' ,'hn_kappa' ,'hn_nu' ,'hn_w_mat' }
190
187
191
- def set_h_params (self ,** kwargs ):
188
+ def set_h_params (self ,h_m_vec , h_kappa , h_nu , h_w_mat ):
192
189
"""Set the hyperparameters of the prior distribution.
193
190
194
191
Parameters
195
192
----------
196
- **kwargs
197
- a python dictionary {'h_m_vec':ndarray, 'h_kappa':float, 'h_nu':float, 'h_w_mat':ndarray} or
198
- {'h0_m_vec':ndarray, 'h0_kappa':float, 'h0_nu':float, 'h0_w_mat':ndarray}
199
- or {'hn_m_vec':ndarray, 'hn_kappa':float, 'hn_nu':float, 'hn_w_mat':ndarray}
200
- They are obtained by ``get_h_params()`` of GenModel,
201
- ``get_h0_params`` of LearnModel or ``get_hn_params`` of LearnModel.
193
+ h_m_vec : numpy.ndarray
194
+ a vector of real numbers
195
+ h_kappa : float
196
+ a positive real number
197
+ h_nu : float
198
+ a real number > degree-1
199
+ h_w_mat : numpy.ndarray
200
+ a positive definite symetric matrix
202
201
"""
203
- if kwargs .keys () == self ._H_PARAM_KEYS :
204
- self .h_m_vec = _check .float_vec (kwargs ['h_m_vec' ],'h_m_vec' ,ParameterFormatError )
205
- self .h_kappa = _check .pos_float (kwargs ['h_kappa' ],'h_kappa' ,ParameterFormatError )
206
- self .h_nu = _check .pos_float (kwargs ['h_nu' ],'h_nu' ,ParameterFormatError )
207
- self .h_w_mat = _check .pos_def_sym_mat (kwargs ['h_w_mat' ],'h_w_mat' ,ParameterFormatError )
208
- elif kwargs .keys () == self ._H0_PARAM_KEYS :
209
- self .h_m_vec = _check .float_vec (kwargs ['h0_m_vec' ],'h_m_vec' ,ParameterFormatError )
210
- self .h_kappa = _check .pos_float (kwargs ['h0_kappa' ],'h_kappa' ,ParameterFormatError )
211
- self .h_nu = _check .pos_float (kwargs ['h0_nu' ],'h_nu' ,ParameterFormatError )
212
- self .h_w_mat = _check .pos_def_sym_mat (kwargs ['h0_w_mat' ],'h_w_mat' ,ParameterFormatError )
213
- elif kwargs .keys () == self ._HN_PARAM_KEYS :
214
- self .h_m_vec = _check .float_vec (kwargs ['hn_m_vec' ],'h_m_vec' ,ParameterFormatError )
215
- self .h_kappa = _check .pos_float (kwargs ['hn_kappa' ],'h_kappa' ,ParameterFormatError )
216
- self .h_nu = _check .pos_float (kwargs ['hn_nu' ],'h_nu' ,ParameterFormatError )
217
- self .h_w_mat = _check .pos_def_sym_mat (kwargs ['hn_w_mat' ],'h_w_mat' ,ParameterFormatError )
218
- else :
219
- raise (ParameterFormatError (
220
- "The input of this function must be a python dictionary with keys:"
221
- + str (self ._H_PARAM_KEYS )+ " or "
222
- + str (self ._H0_PARAM_KEYS )+ " or "
223
- + str (self ._HN_PARAM_KEYS )+ "." )
224
- )
202
+ self .h_m_vec = _check .float_vec (h_m_vec ,'h_m_vec' ,ParameterFormatError )
203
+ self .h_w_mat = _check .pos_def_sym_mat (h_w_mat ,'h_w_mat' ,ParameterFormatError )
204
+ self .h_nu = _check .pos_float (h_nu ,'h_nu' ,ParameterFormatError )
205
+ self .h_kappa = _check .pos_float (h_kappa ,'h_kappa' ,ParameterFormatError )
225
206
226
207
if (self .h_m_vec .shape [0 ] != self .h_w_mat .shape [0 ]
227
208
or self .h_nu <= self .h_m_vec .shape [0 ] - 1 ):
@@ -510,44 +491,24 @@ def __init__(self,degree=None,h0_m_vec=None,h0_kappa=1.0,h0_nu=None,h0_w_mat=Non
510
491
self .p_v_mat = self .hn_kappa * self .p_nu / (self .hn_kappa + 1 ) * self .hn_w_mat
511
492
self .p_v_mat_inv = (self .hn_kappa + 1 )/ self .hn_kappa / self .p_nu * self .hn_w_mat_inv
512
493
513
- self ._H_PARAM_KEYS = {'h_m_vec' ,'h_kappa' ,'h_nu' ,'h_w_mat' }
514
- self ._H0_PARAM_KEYS = {'h0_m_vec' ,'h0_kappa' ,'h0_nu' ,'h0_w_mat' }
515
- self ._HN_PARAM_KEYS = {'hn_m_vec' ,'hn_kappa' ,'hn_nu' ,'hn_w_mat' }
516
-
517
- def set_h0_params (self ,** kwargs ):
494
+ def set_h0_params (self ,h0_m_vec ,h0_kappa ,h0_nu ,h0_w_mat ):
518
495
"""Set the hyperparameters of the prior distribution.
519
496
520
497
Parameters
521
498
----------
522
- **kwargs
523
- a python dictionary {'h_m_vec':ndarray, 'h_kappa':float, 'h_nu':float, 'h_w_mat':ndarray} or
524
- {'h0_m_vec':ndarray, 'h0_kappa':float, 'h0_nu':float, 'h0_w_mat':ndarray}
525
- or {'hn_m_vec':ndarray, 'hn_kappa':float, 'hn_nu':float, 'hn_w_mat':ndarray}
526
- They are obtained by ``get_h_params()`` of GenModel,
527
- ``get_h0_params`` of LearnModel or ``get_hn_params`` of LearnModel.
499
+ h0_m_vec : numpy.ndarray
500
+ a vector of real numbers
501
+ h0_kappa : float
502
+ a positive real number
503
+ h0_nu : float
504
+ a real number > degree-1
505
+ h0_w_mat : numpy.ndarray
506
+ a positive definite symetric matrix
528
507
"""
529
- if kwargs .keys () == self ._H_PARAM_KEYS :
530
- self .h0_m_vec = _check .float_vec (kwargs ['h_m_vec' ],'h0_m_vec' ,ParameterFormatError )
531
- self .h0_kappa = _check .pos_float (kwargs ['h_kappa' ],'h0_kappa' ,ParameterFormatError )
532
- self .h0_nu = _check .pos_float (kwargs ['h_nu' ],'h0_nu' ,ParameterFormatError )
533
- self .h0_w_mat = _check .pos_def_sym_mat (kwargs ['h_w_mat' ],'h0_w_mat' ,ParameterFormatError )
534
- elif kwargs .keys () == self ._H0_PARAM_KEYS :
535
- self .h0_m_vec = _check .float_vec (kwargs ['h0_m_vec' ],'h0_m_vec' ,ParameterFormatError )
536
- self .h0_kappa = _check .pos_float (kwargs ['h0_kappa' ],'h0_kappa' ,ParameterFormatError )
537
- self .h0_nu = _check .pos_float (kwargs ['h0_nu' ],'h0_nu' ,ParameterFormatError )
538
- self .h0_w_mat = _check .pos_def_sym_mat (kwargs ['h0_w_mat' ],'h0_w_mat' ,ParameterFormatError )
539
- elif kwargs .keys () == self ._HN_PARAM_KEYS :
540
- self .h0_m_vec = _check .float_vec (kwargs ['hn_m_vec' ],'h0_m_vec' ,ParameterFormatError )
541
- self .h0_kappa = _check .pos_float (kwargs ['hn_kappa' ],'h0_kappa' ,ParameterFormatError )
542
- self .h0_nu = _check .pos_float (kwargs ['hn_nu' ],'h0_nu' ,ParameterFormatError )
543
- self .h0_w_mat = _check .pos_def_sym_mat (kwargs ['hn_w_mat' ],'h0_w_mat' ,ParameterFormatError )
544
- else :
545
- raise (ParameterFormatError (
546
- "The input of this function must be a python dictionary with keys:"
547
- + str (self ._H_PARAM_KEYS )+ " or "
548
- + str (self ._H0_PARAM_KEYS )+ " or "
549
- + str (self ._HN_PARAM_KEYS )+ "." )
550
- )
508
+ self .h0_m_vec = _check .float_vec (h0_m_vec ,'h0_m_vec' ,ParameterFormatError )
509
+ self .h0_kappa = _check .pos_float (h0_kappa ,'h0_kappa' ,ParameterFormatError )
510
+ self .h0_nu = _check .pos_float (h0_nu ,'h0_nu' ,ParameterFormatError )
511
+ self .h0_w_mat = _check .pos_def_sym_mat (h0_w_mat ,'h0_w_mat' ,ParameterFormatError )
551
512
552
513
if (self .h0_m_vec .shape [0 ] != self .h0_w_mat .shape [0 ]
553
514
or self .h0_nu <= self .h0_m_vec .shape [0 ] - 1 ):
@@ -573,40 +534,24 @@ def get_h0_params(self):
573
534
"""
574
535
return {"h0_m_vec" :self .h0_m_vec , "h0_kappa" :self .h0_kappa , "h0_nu" :self .h0_nu , "h0_w_mat" :self .h0_w_mat }
575
536
576
- def set_hn_params (self ,** kwargs ):
537
+ def set_hn_params (self ,hn_m_vec , hn_kappa , hn_nu , hn_w_mat ):
577
538
"""Set updated values of the hyperparameter of the posterior distribution.
578
539
579
540
Parameters
580
541
----------
581
- **kwargs
582
- a python dictionary {'h_m_vec':ndarray, 'h_kappa':float, 'h_nu':float, 'h_w_mat':ndarray} or
583
- {'h0_m_vec':ndarray, 'h0_kappa':float, 'h0_nu':float, 'h0_w_mat':ndarray}
584
- or {'hn_m_vec':ndarray, 'hn_kappa':float, 'hn_nu':float, 'hn_w_mat':ndarray}
585
- They are obtained by ``get_h_params()`` of GenModel,
586
- ``get_h0_params`` of LearnModel or ``get_hn_params`` of LearnModel.
542
+ hn_m_vec : numpy.ndarray
543
+ a vector of real numbers
544
+ hn_kappa : float
545
+ a positive real number
546
+ hn_nu : float
547
+ a real number > degree-1
548
+ hn_w_mat : numpy.ndarray
549
+ a positive definite symetric matrix
587
550
"""
588
- if kwargs .keys () == self ._H_PARAM_KEYS :
589
- self .hn_m_vec = _check .float_vec (kwargs ['h_m_vec' ],'hn_m_vec' ,ParameterFormatError )
590
- self .hn_kappa = _check .pos_float (kwargs ['h_kappa' ],'hn_kappa' ,ParameterFormatError )
591
- self .hn_nu = _check .pos_float (kwargs ['h_nu' ],'hn_nu' ,ParameterFormatError )
592
- self .hn_w_mat = _check .pos_def_sym_mat (kwargs ['h_w_mat' ],'hn_w_mat' ,ParameterFormatError )
593
- elif kwargs .keys () == self ._H0_PARAM_KEYS :
594
- self .hn_m_vec = _check .float_vec (kwargs ['h0_m_vec' ],'hn_m_vec' ,ParameterFormatError )
595
- self .hn_kappa = _check .pos_float (kwargs ['h0_kappa' ],'hn_kappa' ,ParameterFormatError )
596
- self .hn_nu = _check .pos_float (kwargs ['h0_nu' ],'hn_nu' ,ParameterFormatError )
597
- self .hn_w_mat = _check .pos_def_sym_mat (kwargs ['h0_w_mat' ],'hn_w_mat' ,ParameterFormatError )
598
- elif kwargs .keys () == self ._HN_PARAM_KEYS :
599
- self .hn_m_vec = _check .float_vec (kwargs ['hn_m_vec' ],'hn_m_vec' ,ParameterFormatError )
600
- self .hn_kappa = _check .pos_float (kwargs ['hn_kappa' ],'hn_kappa' ,ParameterFormatError )
601
- self .hn_nu = _check .pos_float (kwargs ['hn_nu' ],'hn_nu' ,ParameterFormatError )
602
- self .hn_w_mat = _check .pos_def_sym_mat (kwargs ['hn_w_mat' ],'hn_w_mat' ,ParameterFormatError )
603
- else :
604
- raise (ParameterFormatError (
605
- "The input of this function must be a python dictionary with keys:"
606
- + str (self ._H_PARAM_KEYS )+ " or "
607
- + str (self ._H0_PARAM_KEYS )+ " or "
608
- + str (self ._HN_PARAM_KEYS )+ "." )
609
- )
551
+ self .hn_m_vec = _check .float_vec (hn_m_vec ,'hn_m_vec' ,ParameterFormatError )
552
+ self .hn_kappa = _check .pos_float (hn_kappa ,'hn_kappa' ,ParameterFormatError )
553
+ self .hn_nu = _check .pos_float (hn_nu ,'hn_nu' ,ParameterFormatError )
554
+ self .hn_w_mat = _check .pos_def_sym_mat (hn_w_mat ,'hn_w_mat' ,ParameterFormatError )
610
555
611
556
if (self .hn_m_vec .shape [0 ] != self .hn_w_mat .shape [0 ]
612
557
or self .hn_nu <= self .hn_m_vec .shape [0 ] - 1 ):
0 commit comments