@@ -5,26 +5,26 @@ type BivariateKDE{Rx<:Range,Ry<:Range} <: AbstractKDE
5
5
density:: Matrix{Float64}
6
6
end
7
7
8
- function kernel_dist {D<:UnivariateDistribution} (:: Type{D} ,w:: (@compat Tuple{Real,Real}) )
8
+ function kernel_dist {D<:UnivariateDistribution} (:: Type{D} ,w:: Tuple{Real,Real} )
9
9
kernel_dist (D,w[1 ]), kernel_dist (D,w[2 ])
10
10
end
11
- function kernel_dist {Dx<:UnivariateDistribution,Dy<:UnivariateDistribution} (:: Type{(@compat Tuple{Dx, Dy}) } ,w:: (@compat Tuple{Real,Real}) )
11
+ function kernel_dist {Dx<:UnivariateDistribution,Dy<:UnivariateDistribution} (:: Type{Tuple{Dx, Dy}} ,w:: Tuple{Real,Real} )
12
12
kernel_dist (Dx,w[1 ]), kernel_dist (Dy,w[2 ])
13
13
end
14
14
15
15
# this function provided for backwards compatibility, though it doesn't have the type restrictions
16
16
# to ensure that the given tuple only contains univariate distributions
17
- function kernel_dist (d:: (@compat Tuple{DataType, DataType}) , w:: (@compat Tuple{Real,Real}) )
17
+ function kernel_dist (d:: Tuple{DataType, DataType} , w:: Tuple{Real,Real} )
18
18
kernel_dist (d[1 ],w[1 ]), kernel_dist (d[2 ],w[2 ])
19
19
end
20
20
21
21
# TODO : there are probably better choices.
22
- function default_bandwidth (data:: (@compat Tuple{RealVector,RealVector}) )
22
+ function default_bandwidth (data:: Tuple{RealVector,RealVector} )
23
23
default_bandwidth (data[1 ]), default_bandwidth (data[2 ])
24
24
end
25
25
26
26
# tabulate data for kde
27
- function tabulate (data:: (@compat Tuple{RealVector, RealVector}) , midpoints:: (@compat Tuple{Range, Range}) )
27
+ function tabulate (data:: Tuple{RealVector, RealVector} , midpoints:: Tuple{Range, Range} )
28
28
xdata, ydata = data
29
29
ndata = length (xdata)
30
30
length (ydata) == ndata || error (" data vectors must be of same length" )
@@ -54,7 +54,7 @@ function tabulate(data::(@compat Tuple{RealVector, RealVector}), midpoints::(@co
54
54
end
55
55
56
56
# convolution with product distribution of two univariates distributions
57
- function conv (k:: BivariateKDE , dist:: (@compat Tuple{UnivariateDistribution,UnivariateDistribution}) )
57
+ function conv (k:: BivariateKDE , dist:: Tuple{UnivariateDistribution,UnivariateDistribution} )
58
58
# Transform to Fourier basis
59
59
Kx, Ky = size (k. density)
60
60
ft = rfft (k. density)
@@ -79,37 +79,37 @@ function conv(k::BivariateKDE, dist::(@compat Tuple{UnivariateDistribution,Univa
79
79
BivariateKDE (k. x, k. y, dens)
80
80
end
81
81
82
- typealias BivariateDistribution @compat ( Union{MultivariateDistribution,Tuple{UnivariateDistribution,UnivariateDistribution}})
82
+ typealias BivariateDistribution Union{MultivariateDistribution,Tuple{UnivariateDistribution,UnivariateDistribution}}
83
83
84
- function kde (data:: (@compat Tuple{RealVector, RealVector}) , midpoints:: (@compat Tuple{Range, Range}) , dist:: BivariateDistribution )
84
+ function kde (data:: Tuple{RealVector, RealVector} , midpoints:: Tuple{Range, Range} , dist:: BivariateDistribution )
85
85
k = tabulate (data,midpoints)
86
86
conv (k,dist)
87
87
end
88
88
89
- function kde (data:: (@compat Tuple{RealVector, RealVector}) , dist:: BivariateDistribution ;
90
- boundary:: (@compat Tuple{(@compat Tuple{Real,Real}) ,( @compat Tuple{Real,Real})}) = (kde_boundary (data[1 ],std (dist[1 ])),
89
+ function kde (data:: Tuple{RealVector, RealVector} , dist:: BivariateDistribution ;
90
+ boundary:: Tuple{Tuple{Real,Real}, Tuple{Real,Real}} = (kde_boundary (data[1 ],std (dist[1 ])),
91
91
kde_boundary (data[2 ],std (dist[2 ]))),
92
- npoints:: (@compat Tuple{Int,Int}) = (256 ,256 ))
92
+ npoints:: Tuple{Int,Int} = (256 ,256 ))
93
93
94
94
xmid = kde_range (boundary[1 ],npoints[1 ])
95
95
ymid = kde_range (boundary[2 ],npoints[2 ])
96
96
97
97
kde (data,(xmid,ymid),dist)
98
98
end
99
99
100
- function kde (data:: (@compat Tuple{RealVector, RealVector}) , midpoints:: (@compat Tuple{Range, Range}) ;
100
+ function kde (data:: Tuple{RealVector, RealVector} , midpoints:: Tuple{Range, Range} ;
101
101
bandwidth= default_bandwidth (data), kernel= Normal)
102
102
103
103
dist = kernel_dist (kernel,bandwidth)
104
104
kde (data,midpoints,dist)
105
105
end
106
106
107
- function kde (data:: (@compat Tuple{RealVector, RealVector}) ;
107
+ function kde (data:: Tuple{RealVector, RealVector} ;
108
108
bandwidth= default_bandwidth (data),
109
109
kernel= Normal,
110
- boundary:: (@compat Tuple{(@compat Tuple{Real,Real}) ,( @compat Tuple{Real,Real})}) = (kde_boundary (data[1 ],bandwidth[1 ]),
110
+ boundary:: Tuple{Tuple{Real,Real}, Tuple{Real,Real}} = (kde_boundary (data[1 ],bandwidth[1 ]),
111
111
kde_boundary (data[2 ],bandwidth[2 ])),
112
- npoints:: (@compat Tuple{Int,Int}) = (256 ,256 ))
112
+ npoints:: Tuple{Int,Int} = (256 ,256 ))
113
113
114
114
dist = kernel_dist (kernel,bandwidth)
115
115
xmid = kde_range (boundary[1 ],npoints[1 ])
0 commit comments