Skip to content

Commit fccb6b9

Browse files
committed
Update to reflect changes
1 parent 07a9702 commit fccb6b9

File tree

1 file changed

+18
-17
lines changed

1 file changed

+18
-17
lines changed

README.md

+18-17
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ The package defines an abstract `Divergence` type with the following suptypes:
1414
* Reverse Kullback-Leibler divergence `ReverseKullbackLeibler`
1515
* Cressie-Read divergences `CressieRead`
1616

17-
These divergences differ from the equivalent ones defined in the `Distances` package because they are normalized. Also, the package provides methods for calculating their gradient and the (diagonal elements of the) Hessian matrix.
17+
These divergences differ from the equivalent ones defined in the `Distances` package because they are **normalized**.
18+
19+
Also, the package provides methods for calculating their gradient and the (diagonal elements of the) Hessian matrix.
1820

1921
The constructors for the types above are straightforward
2022
```julia
@@ -52,28 +54,25 @@ FullyModifiedCressieRead(alpha::Real, phi::Real, theta::Real)
5254
Each divergence corresponds to a *divergence type*. You can always compute a certain divergence between two vectors using the following syntax
5355

5456
```julia
55-
d = evaluate(div, x, y)
57+
x = rand(100)
58+
y = rand(100)
59+
𝒦ℒ = KullbackLeibler()
60+
𝒦ℒ(x, y)
5661
```
5762

58-
Here, `div` is an instance of a divergence type. For example, the type for Kullback Leibler divergence is ``KullbackLeibler`` (more divergence types are described in some detail in what follows), then the Kullback Leibler divergence between ``x`` and ``y`` can be computed
59-
```julia
60-
d = evaluate(KullbackLeibler(), x, y)
61-
```
63+
Here, `div` is an instance of a divergence type.
6264

6365
We can also calculate the divergence between the vector ``x`` and the unit vector
6466
```julia
65-
r = evaluate(KullbackLeibler(), x)
67+
r = 𝒦ℒ(x)
6668
```
6769

68-
The `Divergence` type is a subtype of `PreMetric` defined in the `Distances` package. As such, the divergences can be evaluated row-wise and column-wise for `X::Matrix` and `Y::Matrix`.
70+
The `Divergence` type is a subtype of `PreMetric` defined in the `Distances` package. As such, the divergences can be evaluated column-wise for `X::Matrix` and `Y::Matrix`.
6971

7072
```julia
71-
rowise(div, X, Y)
73+
colwise(𝒦ℒ, X, Y)
7274
```
7375

74-
```julia
75-
colwise(div, X, Y)
76-
```
7776

7877
### Gradient of the divergence
7978

@@ -84,7 +83,8 @@ g = gradient(div, x, y)
8483
```
8584
or through its in-place version
8685
```julia
87-
gradient!(Array(Float64, size(x)), div, x, y)
86+
u = Vector{Float64}(undef, size(x))
87+
gradient!(u, div, x, y)
8888
```
8989

9090
### Hessian of the divergence
@@ -94,12 +94,13 @@ h = hessian(div, x, y)
9494
```
9595
Its in-place variant is also defined
9696
```julia
97-
hessian!(Array(Float64, size(x)), div, x, y)
97+
u = Vector{Float64}(undef, size(x))
98+
hessian!(u, div, x, y)
9899
```
99100

100-
Notice that the the divergence's Hessian is sparse, where the diagonal entries are the only ones different from zero. For this reason, `hessian(div, x, y)` returns an `Array{Float64,1}` with the diagonal entries of the hessian.
101+
Notice that the the divergence's Hessian is sparse, where the diagonal entries are the only ones different from zero. For this reason, `hessian(div, x, y)` returns an `Array{T,1}` with the diagonal entries of the hessian.
102+
103+
101104

102-
## List of divergences
103105

104-
[To be added]
105106

0 commit comments

Comments
 (0)