|
MINKOWSKI DISTANCEName:
The case where p = 1 is equivalent to the Manhattan distance and the case where p = 2 is equivalent to the Euclidean distance. Although p can be any real value, it is typically set to a value between 1 and 2. For values of p less than 1, the formula above does not define a valid distance metric since the triange inequality is not satisfied. The value of p is specified by entering the command
before entering the MINKOWSKI DISTANCE command. If p is not specified, a default value of p = 1 will be used.
where <y1> is the first response variable; <y2> is the second response variable; <par> is a parameter where the computed Minkowski distance is stored; and where the <SUBSET/EXCEPT/FOR qualification> is optional.
LET A = MINKOWSKI DISTANCE Y1 Y2 LET A = MINKOWSKI DISTANCE Y1 Y2 SUBSET Y1 > 0 SUBSET Y2 > 0
SKIP 25
READ IRIS.DAT Y1 TO Y4 X
LET P = 1.5
.
LET DIST = MINKOWSKI DISTANCE Y1 Y2
SET WRITE DECIMALS 4
TABULATE MINKOWSKI DISTANCE Y1 Y2 X
Cross Tabulate MINKOWSKI DISTANCE
(Response Variables: Y1 Y2 )
---------------------------------------------
X | MINKOWSKI DISTA
---------------------------------------------
1.0000 | 21.5631
2.0000 | 43.1725
3.0000 | 49.3414
.
XTIC OFFSET 0.2 0.2
X1LABEL GROUP ID
LET NDIST = UNIQUE X
XLIMITS 1 NDIST
MAJOR X1TIC MARK NUMBER NDIST
MINOR X1TIC MARK NUMBER 0
CHAR X
LINE BLANK
LABEL CASE ASIS
CASE ASIS
TITLE CASE ASIS
TITLE OFFSET 2
.
TITLE Minkowski Distance with P = 1.5 (IRIS.DAT)
Y1LABEL Minkowski Distance
MINKOWSKI DISTANCE PLOT Y1 Y2 X
set write decimals 3
dimension 100 columns
.
skip 25
read iris.dat y1 y2 y3 y4
skip 0
.
let p = 1.5
let z = generate matrix minkowski distance y1 y2 y3 y4
print z
The following output is generated
MATRIX Z -- 4 ROWS
-- 4 COLUMNS
VARIABLES--Z1 Z2 Z3 Z4
0.000 5.100 5.600 6.600
5.100 0.000 4.300 4.000
5.600 4.300 0.000 4.700
6.600 4.000 4.700 0.000
|
Privacy
Policy/Security Notice
NIST is an agency of the U.S.
Commerce Department.
Date created: 08/31/2017 | |||||||||||||||||||