@@ -9,7 +9,12 @@ import Base: +, *, /, -
9
9
pdf_matrix (d:: UnivariateFinite , L) = pdf .(d, L)
10
10
pdf_matrix (d:: AbstractArray{<:UnivariateFinite} , L) = pdf (d, L)
11
11
12
- function + (d1:: U , d2:: U ) where U <: SingletonOrArray
12
+ function + (d1:: UnivariateFinite{S, V} , d2:: UnivariateFinite{S, V} ) where {S, V}
13
+ L = classes (d1)
14
+ L == classes (d2) || throw (ERR_DIFFERENT_SAMPLE_SPACES)
15
+ return UnivariateFinite (L, pdf_matrix (d1, L) + pdf_matrix (d2, L))
16
+ end
17
+ function + (d1:: UnivariateFiniteArray{S, V} , d2:: UnivariateFiniteArray{S, V} ) where {S, V}
13
18
L = classes (d1)
14
19
L == classes (d2) || throw (ERR_DIFFERENT_SAMPLE_SPACES)
15
20
return UnivariateFinite (L, pdf_matrix (d1, L) + pdf_matrix (d2, L))
27
32
- (d:: UnivariateFinite ) = _minus (d, UnivariateFinite)
28
33
- (d:: UnivariateFiniteArray ) = _minus (d, UnivariateFiniteArray)
29
34
30
- function - (d1:: U , d2:: U ) where U <: SingletonOrArray
35
+ function - (d1:: UnivariateFinite{S, V} , d2:: UnivariateFinite{S, V} ) where {S, V}
36
+ L = classes (d1)
37
+ L == classes (d2) || throw (ERR_DIFFERENT_SAMPLE_SPACES)
38
+ return UnivariateFinite (L, pdf_matrix (d1, L) - pdf_matrix (d2, L))
39
+ end
40
+ function - (d1:: UnivariateFiniteArray{S, V} , d2:: UnivariateFiniteArray{S, V} ) where {S, V}
31
41
L = classes (d1)
32
42
L == classes (d2) || throw (ERR_DIFFERENT_SAMPLE_SPACES)
33
43
return UnivariateFinite (L, pdf_matrix (d1, L) - pdf_matrix (d2, L))
0 commit comments