@@ -19,8 +19,6 @@ class AbstractMixtures(metaclass=ABCMeta):
1919 def __init__ (
2020 self ,
2121 mixture_form : str ,
22- integrator_cls : Type [Integrator ] = RQMCIntegrator ,
23- integrator_params : Dict [str , Any ] = None ,
2422 ** kwargs : Any
2523 ) -> None :
2624 """
@@ -31,8 +29,7 @@ def __init__(
3129 **kwargs: Parameters of Mixture (alpha, gamma, etc.)
3230 """
3331 self .mixture_form = mixture_form
34- self .integrator_cls = integrator_cls
35- self .integrator_params = integrator_params or {}
32+
3633
3734 if mixture_form == "classical" :
3835 self .params = self ._params_validation (self ._classical_collector , kwargs )
@@ -42,70 +39,74 @@ def __init__(
4239 raise AssertionError (f"Unknown mixture form: { mixture_form } " )
4340
4441 @abstractmethod
45- def _compute_moment (self , n : int ) -> Tuple [float , float ]:
42+ def _compute_moment (self , n : int , integrator : Integrator ) -> Tuple [float , float ]:
4643 ...
4744
4845 def compute_moment (
4946 self ,
50- x : Union [List [int ], int , NDArray [np .float64 ]]
47+ x : Union [List [int ], int , NDArray [np .float64 ]],
48+ integrator : Integrator
5149 ) -> Union [List [Tuple [float , float ]], Tuple [float , float ], NDArray [Any ]]:
5250 if isinstance (x , np .ndarray ):
53- return np .array ([self ._compute_moment (xp ) for xp in x ], dtype = object )
51+ return np .array ([self ._compute_moment (xp , integrator ) for xp in x ], dtype = object )
5452 elif isinstance (x , list ):
55- return [self ._compute_moment (xp ) for xp in x ]
53+ return [self ._compute_moment (xp , integrator ) for xp in x ]
5654 elif isinstance (x , int ):
57- return self ._compute_moment (x )
55+ return self ._compute_moment (x , integrator )
5856 else :
5957 raise TypeError (f"Unsupported type for x: { type (x )} " )
6058
6159 @abstractmethod
62- def _compute_pdf (self , x : float ) -> Tuple [float , float ]:
60+ def _compute_pdf (self , x : float , integrator : Integrator ) -> Tuple [float , float ]:
6361 ...
6462
6563 def compute_pdf (
6664 self ,
67- x : Union [List [float ], float , NDArray [np .float64 ]]
65+ x : Union [List [float ], float , NDArray [np .float64 ]],
66+ integrator : Integrator
6867 ) -> Union [List [Tuple [float , float ]], Tuple [float , float ], NDArray [Any ]]:
6968 if isinstance (x , np .ndarray ):
70- return np .array ([self ._compute_pdf (xp ) for xp in x ], dtype = object )
69+ return np .array ([self ._compute_pdf (xp , integrator ) for xp in x ], dtype = object )
7170 elif isinstance (x , list ):
72- return [self ._compute_pdf (xp ) for xp in x ]
71+ return [self ._compute_pdf (xp , integrator ) for xp in x ]
7372 elif isinstance (x , float ):
74- return self ._compute_pdf (x )
73+ return self ._compute_pdf (x , integrator )
7574 else :
7675 raise TypeError (f"Unsupported type for x: { type (x )} " )
7776
7877 @abstractmethod
79- def _compute_logpdf (self , x : float ) -> Tuple [float , float ]:
78+ def _compute_logpdf (self , x : float , integrator : Integrator ) -> Tuple [float , float ]:
8079 ...
8180
8281 def compute_logpdf (
8382 self ,
84- x : Union [List [float ], float , NDArray [np .float64 ]]
83+ x : Union [List [float ], float , NDArray [np .float64 ]],
84+ integrator : Integrator
8585 ) -> Union [List [Tuple [float , float ]], Tuple [float , float ], NDArray [Any ]]:
8686 if isinstance (x , np .ndarray ):
87- return np .array ([self ._compute_logpdf (xp ) for xp in x ], dtype = object )
87+ return np .array ([self ._compute_logpdf (xp , integrator ) for xp in x ], dtype = object )
8888 elif isinstance (x , list ):
89- return [self ._compute_logpdf (xp ) for xp in x ]
89+ return [self ._compute_logpdf (xp , integrator ) for xp in x ]
9090 elif isinstance (x , float ):
91- return self ._compute_logpdf (x )
91+ return self ._compute_logpdf (x , integrator )
9292 else :
9393 raise TypeError (f"Unsupported type for x: { type (x )} " )
9494
9595 @abstractmethod
96- def _compute_cdf (self , x : float ) -> Tuple [float , float ]:
96+ def _compute_cdf (self , x : float , integrator : Integrator ) -> Tuple [float , float ]:
9797 ...
9898
9999 def compute_cdf (
100100 self ,
101- x : Union [List [float ], float , NDArray [np .float64 ]]
101+ x : Union [List [float ], float , NDArray [np .float64 ]],
102+ integrator : Integrator
102103 ) -> Union [List [Tuple [float , float ]], Tuple [float , float ], NDArray [Any ]]:
103104 if isinstance (x , np .ndarray ):
104- return np .array ([self ._compute_cdf (xp ) for xp in x ], dtype = object )
105+ return np .array ([self ._compute_cdf (xp , integrator ) for xp in x ], dtype = object )
105106 elif isinstance (x , list ):
106- return [self ._compute_cdf (xp ) for xp in x ]
107+ return [self ._compute_cdf (xp , integrator ) for xp in x ]
107108 elif isinstance (x , float ):
108- return self ._compute_cdf (x )
109+ return self ._compute_cdf (x , integrator )
109110 else :
110111 raise TypeError (f"Unsupported type for x: { type (x )} " )
111112
0 commit comments