Description Usage Arguments Value Author(s) Examples
View source: R/unit.distances.R
Function somgrid
(modified from the version in the class
package) sets up a grid of units, of a specified size
and topology. Distances between grid units are calculated by function
unit.distances
.
1 2 3 |
xdim, ydim |
dimensions of the grid. |
topo |
choose between a hexagonal or rectangular topology. |
neighbourhood.fct |
choose between bubble and gaussian neighbourhoods when training a SOM. |
toroidal |
logical, whether the grid is toroidal or not. If not
provided to the |
grid |
an object of class |
Function somgrid
returns an object of class "somgrid", with
elements pts
, and the input arguments to the function.
Function unit.distances
returns a (symmetrical) matrix
containing distances. When grid$n.hood
equals "circular",
Euclidean distances are used; for grid$n.hood
is "square"
maximum distances. For toroidal maps (joined at the edges) distances
are calculated for the shortest path.
Ron Wehrens
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | mygrid <- somgrid(5, 5, "hexagonal")
fakesom <- list(grid = mygrid)
class(fakesom) <- "kohonenDTW"
par(mfrow = c(2,1))
dists <- unit.distances(mygrid)
plot(fakesom, type="property", property = dists[1,],
main="Distances to unit 1", zlim=c(0,6),
palette = rainbow, ncolors = 7)
dists <- unit.distances(mygrid, toroidal=TRUE)
plot(fakesom, type="property", property = dists[1,],
main="Distances to unit 1 (toroidal)", zlim=c(0,6),
palette = rainbow, ncolors = 7)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.