forked from pdollar/toolbox
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsoftMin.html
90 lines (71 loc) · 3.67 KB
/
softMin.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
<title>Description of softMin</title>
<meta name="keywords" content="softMin">
<meta name="description" content="Calculates the softMin of a vector.">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="generator" content="m2html © 2003 Guillaume Flandin">
<meta name="robots" content="index, follow">
<link type="text/css" rel="stylesheet" href="../m2html.css">
</head>
<body>
<a name="_top"></a>
<!-- menu.html classify -->
<h1>softMin
</h1>
<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="box"><strong>Calculates the softMin of a vector.</strong></div>
<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="box"><strong>function M = softMin( D, sigma ) </strong></div>
<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="fragment"><pre class="comment"> Calculates the softMin of a vector.
Let D be a vector. Then the softMin of D is defined as:
s = exp(-D/sigma^2) / sum( exp(-D/sigma^2) )
The softMin is a way of taking a dissimilarity (distance) vector D and
converting it to a similarity vector s, such that sum(s)==1. If D is an
NxK array, is is treated as N K-dimensional vectors, and the return is
likewise an NxK array. This is useful if D is a distance matrix,
generated by the likes of pdist2.
Note that as sigma->0, softMin's behavior tends toward that of the
standard min function. That is the softMin of a vector D has all zeros
with a single 1 in the location of the smallest value of D. For example,
"softMin([.2 .4 .1 .3],eps)" returns "[0 0 1 0]". As sigma->inf, then
softMin(D,sigma) tends toward "ones(1,n)/n", where n==length(D).
If D contains the squared euclidean distance between a point y and k
points xi, then there is a probabilistic interpretation for softMin. If
we think of the k points representing equal variant gaussians each with
mean xi and std sigma, then the softMin returns the relative probability
of y being generated by each gaussian.
USAGE
M = softMin( D, sigma )
INPUTS
D - NxK dissimilarity matrix
sigma - controls 'softness' of softMin
OUTPUTS
M - the softMin (indexes into D)
EXAMPLE - 1
C = [0 0; 1 0; 0 1; 1 1]; x=[.7,.3; .1 .2];
D = pdist2( x, C ), M = softMin( D, .25 )
EXAMPLE - 2
fplot( 'softMin( [0.5 0.2 .4], x )', [0 5] );
xlabel('sigma'); ylabel('assignments')
See also <a href="pdist2.html" class="code" title="function D = pdist2( X, Y, metric )">PDIST2</a>, SOFTMAX
Piotr's Computer Vision Matlab Toolbox Version 2.0
Copyright 2014 Piotr Dollar. [pdollar-at-gmail.com]
Licensed under the Simplified BSD License [see external/bsd.txt]</pre></div>
<!-- Start of Google Analytics Code -->
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
var pageTracker = _gat._getTracker("UA-4884268-1");
pageTracker._initData();
pageTracker._trackPageview();
</script>
<!-- end of Google Analytics Code -->
<hr><address>Generated by <strong><a href="http://www.artefact.tk/software/matlab/m2html/" target="_parent">m2html</a></strong> © 2003</address>
</body>
</html>