Main Content

negdist

Negative distance weight function

Syntax

Z = negdist(W,P)
dim = negdist('size',S,R,FP)
dw = negdist('dz_dw',W,P,Z,FP)

Description

negdist is a weight function. Weight functions apply weights to an input to get weighted inputs.

Z = negdist(W,P) takes these inputs,

W

S-by-R weight matrix

P

R-by-Q matrix of Q input (column) vectors

FP

Row cell array of function parameters (optional, ignored)

and returns the S-by-Q matrix of negative vector distances.

dim = negdist('size',S,R,FP) takes the layer dimension S, input dimension R, and function parameters, and returns the weight size [S-by-R].

dw = negdist('dz_dw',W,P,Z,FP) returns the derivative of Z with respect to W.

Examples

Here you define a random weight matrix W and input vector P and calculate the corresponding weighted input Z.

W = rand(4,3);
P = rand(3,1);
Z = negdist(W,P)

Network Use

You can create a standard network that uses negdist by calling competlayer or selforgmap.

To change a network so an input weight uses negdist, set net.inputWeights{i,j}.weightFcn to 'negdist'. For a layer weight, set net.layerWeights{i,j}.weightFcn to 'negdist'.

In either case, call sim to simulate the network with negdist.

Algorithms

negdist returns the negative Euclidean distance:

z = -sqrt(sum(w-p)^2)

Version History

Introduced before R2006a