File tree Expand file tree Collapse file tree 2 files changed +30
-6
lines changed
Expand file tree Collapse file tree 2 files changed +30
-6
lines changed Original file line number Diff line number Diff line change @@ -13,15 +13,13 @@ pub mod gumbel;
1313pub mod independence;
1414
1515#[ derive( Debug , Clone , Copy ) ]
16- pub enum CopulaType {
16+ pub ( super ) enum CopulaType {
1717 Clayton ,
1818 Frank ,
1919 Gumbel ,
2020 Independence ,
2121}
2222
23- const EPSILON : f64 = 1e-12 ;
24-
2523pub trait Bivariate {
2624 fn r#type ( & self ) -> CopulaType ;
2725
@@ -128,9 +126,7 @@ pub trait Bivariate {
128126 fn pdf ( & self , X : & Array2 < f64 > ) -> Result < Array1 < f64 > , Box < dyn Error > > ;
129127
130128 fn log_pdf ( & self , X : & Array2 < f64 > ) -> Result < Array1 < f64 > , Box < dyn Error > > {
131- let pdf = self . pdf ( X ) ?;
132- let log_pdf = pdf. mapv ( |val| ( val + 1e-32 ) . ln ( ) ) ;
133- Ok ( log_pdf)
129+ Ok ( self . pdf ( X ) ?. ln ( ) )
134130 }
135131
136132 fn cdf ( & self , X : & Array2 < f64 > ) -> Result < Array1 < f64 > , Box < dyn Error > > ;
Original file line number Diff line number Diff line change 1+ use std:: error:: Error ;
2+
3+ use ndarray:: { Array1 , Array2 } ;
4+
15pub mod gaussian;
26pub mod tree;
37pub mod vine;
8+
9+ pub ( super ) enum CopulaType {
10+ Gaussian ,
11+ Tree ,
12+ Vine ,
13+ }
14+
15+ pub trait Multivariate {
16+ fn r#type ( & self ) -> CopulaType ;
17+
18+ fn sample ( & self , n : usize ) -> Result < Array2 < f64 > , Box < dyn Error > > ;
19+
20+ fn fit ( & mut self , X : Array2 < f64 > ) -> Result < ( ) , Box < dyn Error > > ;
21+
22+ fn check_fit ( & self , X : & Array2 < f64 > ) -> Result < ( ) , Box < dyn Error > > ;
23+
24+ fn pdf ( & self , X : Array2 < f64 > ) -> Result < Array1 < f64 > , Box < dyn Error > > ;
25+
26+ fn log_pdf ( & self , X : Array2 < f64 > ) -> Result < Array1 < f64 > , Box < dyn Error > > {
27+ Ok ( self . pdf ( X ) ?. ln ( ) )
28+ }
29+
30+ fn cdf ( & self , X : Array2 < f64 > ) -> Result < Array1 < f64 > , Box < dyn Error > > ;
31+ }
You can’t perform that action at this time.
0 commit comments