estimate_bandwidth
Estimate an appropriate bandwidth for Mean Shift clustering
Syntax
bw = estimate_bandwidth(X [, quantile, n_samples, random_state])
Arguments
- X
is a N x D (N samples, D features) real matrix.
- quantile
real scalar, optional (default=0.3). Quantile to compute the distance bandwidth. A smaller quantile gives a smaller bandwidth, leading to more clusters. A larger quantile produces a larger bandwidth, leading to fewer clusters.
- n_samples
integer, optional (default=min(500, N)). Number of samples to randomly select for bandwidth estimation. If
n_samples > size(data,1)
, all samples are used.- random_state
integer, optional (default=-1). Seed for random sampling reproducibility.
- bw
real scalar. Estimated bandwidth parameter suitable for Mean Shift clustering. Typically corresponds to a quantile of pairwise distances between points.
Description
estimate_bandwidth
computes a bandwidth value from a dataset,
which can be used as the bandwidth
parameter in
meanshift.
Note that:
Smaller quantile → smaller bandwidth → more clusters.
Larger quantile → larger bandwidth → fewer clusters.
Examples
X = [0 0; 0 1; 1 0; 5 5; 5 6; 6 5; 9 9; 9 10; 10 9]; bw = estimate_bandwidth(X); [centers, labels] = meanshift(X, bw); scf(); scatter(X(:,1), X(:,2), [], labels, "fill"); plot(centers(:,1), centers(:,2), 'r*', "markersize", 10, "thickness", 3); gca().data_bounds = [-1 -1; 11 11];

History
Versão | Descrição |
2026.0.0 | Function added. |
Report an issue | ||
<< dbscan | Estatística | kmeans >> |