CentralFeature[{x1,x2,…}]
gives the central feature of the elements
.
CentralFeature[{x1v1,x2v2,…}]
gives the vi corresponding to the central feature
.
CentralFeature[data]
gives the central feature for several different forms of data.
CentralFeature
CentralFeature[{x1,x2,…}]
gives the central feature of the elements
.
CentralFeature[{x1v1,x2v2,…}]
gives the vi corresponding to the central feature
.
CentralFeature[data]
gives the central feature for several different forms of data.
Details and Options
- CentralFeature is a location measure. It gives a point in the data with the minimum total distance to every other point.
- CentralFeature finds the element
that minimizes the sum of distances
for the unweighted case and
for the weighted case. - The data data has the following forms and interpretations:
-
{data1,data2,…} list of data of different formats including numerical, geospatial, textual, visual, dates and times, as well as combinations of these {data1,data2,…}{v1,v2,…} data with indices {v1,v2,…} {data1,data2,…}Automatic take the vi to be successive integers i GeoPosition[…] array of geodetic positions WeightedData[…] data with weights - The following option can be given:
-
DistanceFunction Automatic the distance metric to use - The setting for DistanceFunction can be any distance or dissimilarity function or a function f defining a distance between two points.
- By default, the following distance functions are used for different types of elements:
-
EuclideanDistance numeric data ImageDistance images JaccardDissimilarity Boolean data EditDistance text and nominal sequences Abs[DateDifference[#1,#2]]& dates and times ColorDistance colors GeoDistance geospatial data Boole[SameQ[#1,#2]]& nominal data HammingDistance nominal vector data WarpingDistance numerical sequences - All images are first conformed using ConformImages when the option DistanceFunction is Automatic.
- By default, when data elements are mixed-type vectors, distances are computed independently for each type and combined using Norm.
Examples
open all close allBasic Examples (2)
Find the central feature in a list of vectors:
CentralFeature[{{1., 3., 5.}, {7., 1., 2.}, {9., 3., 1.}, {4., 5., 6.}}]Find the central feature in a list of vectors with given weights:
CentralFeature[WeightedData[{{1., 3., 5.}, {-4., 1., 2.}, {3., 3., 1.}, {4., 5., 6.}}, {1., 3., 4., 5.}]]Scope (9)
Same inputs with different output formats:
data = {{1, 2}, {3, 4}, {8, 7}, {6, 5}, {9, 4}, {1, 3}};CentralFeature[data]CentralFeature[data -> Automatic]CentralFeature[data -> Table[f[i], {i, 6}]]CentralFeature[{{1, 2} -> g[1], {3, 4} -> g[2], {8, 7} -> g[3], {6, 5} -> g[4], {9, 4} -> g[5], {1, 3} -> g[6]}]Central feature works with WeightedData:
wd = WeightedData[{{1., 3.}, {-4., 2.}, {3., 1.}, {5., 6.}}, {1., 3., 4., 5.}];CentralFeature[wd]CentralFeature[wd -> {1, 2, 3, 4}]Central feature of a large array:
CentralFeature[RandomReal[1, {10 ^ 5, 2}]]CentralFeature[WeightedData[RandomReal[1, {10 ^ 5, 3}], RandomReal[1, 10 ^ 5]]]Find the central feature of data involving quantities:
data = Quantity[RandomReal[1, {6, 2}], "Meters"]CentralFeature[data]Find the central feature of a list of images:
CentralFeature[{[image], [image], [image], [image], [image], [image], [image], [image], [image], [image]}]CentralFeature[{[image], [image], [image], [image], [image], [image]}]CentralFeature[{[image], [image], [image], [image], [image]}]Compute the central feature of a TabularColumn object of "String" type:
col = TabularColumn[{"abcd", "bcde", "abab", "abcdef", "agi"}]CentralFeature[col]Compute the central feature of Boolean vectors:
CentralFeature[{{True, False, True}, {True, True, True}, {True, False, False}, {False, False, False}}]Compute the central feature of a list of date objects:
CentralFeature[{DateObject[{1985, 10, 3}], DateObject[{1989, 5, 30}], DateObject[{1999, 11, 15}], DateObject[]}]Compute the central feature of geodetic positions:
cities = {Entity["City", {"Paris", "IleDeFrance", "France"}], Entity["City", {"Sydney", "NewSouthWales", "Australia"}], Entity["City", {"Boston", "Massachusetts", "UnitedStates"}], Entity["City", {"SanFrancisco", "California", "UnitedStates"}], Entity["City", {"Tokyo", "Tokyo", "Japan"}]};cf = CentralFeature[GeoPosition[cities]]GeoGraphics[{GeoPath[Thread[{cf, cities}]], GeoMarker[cities, Gray], GeoMarker[cf, Red]}, GeoProjection -> {"AzimuthalEquidistant", "Centering" -> cf}, GeoRange -> "World", GeoGridLines -> Automatic]Options (2)
DistanceFunction (2)
By default, Euclidean distance is used:
CentralFeature[RandomVariate[NormalDistribution[], {10, 3}]]The ChessboardDistance only takes into account the dimension with the largest separation:
CentralFeature[{{1., 3.}, {-2.6, 4.}, {9.2, 5.}, {7.3, -5.}}, DistanceFunction -> ChessboardDistance]The DistanceFunction can be given as a symbol:
dist[{u_, v_}, {x_, y_}] := Sqrt[3(u - x) ^ 2 + 2(v - y) ^ 2]data = {{1.5, .6}, {2, 0}, {1.25, 1.25}, {3., 0.3}};CentralFeature[data, DistanceFunction -> dist]CentralFeature[data, DistanceFunction -> (Sqrt[{3, 2}.(#1 - #2) ^ 2]&)]Applications (4)
Obtain a robust estimate of multivariate location when outliers are present:
data = {{3., -5.}, {2., -5.}, {0., 2.}, {-4., -3.}, {10 ^ 8, -1.}, {8., -20000}};CentralFeature[data]Extreme values have a large influence on the Mean:
Mean[data]Sample points from a convex polygon:
poly = Polygon[{{2., -5.}, {0., 2.}, {-4., -3.}, {-5, -7}}];
pts = RandomPoint[poly, 10 ^ 3];Graphics[{Lighter[Blue, .9], poly, Black, PointSize[Small], Point[pts]}]Estimate the center of the polygon by computing the central feature of random points:
cf = CentralFeature[pts]Graphics[{Lighter[Blue, .9], poly, Black, PointSize[Small], Point[pts], PointSize[0.06], Red, Point[cf]}]Find the central feature of California, based on the location of cities:
cities = CityData[{All, "California"}];
locations = GeoPosition[CityData[#, "Coordinates"]& /@ cities];unweighted = cities[[CentralFeature[locations -> Automatic]]]Find the central feature of California, based on the location of cities weighted by population:
populations = CityData[#, "Population"]& /@ cities;weighted = cities[[CentralFeature[WeightedData[locations, populations] -> Automatic]]]Draw the cities' locations (gray), unweighted central feature (red) and weighted central feature (black):
legend = PointLegend[{Red, Blue}, {"unweighted central feature", "central feature weighted by population"}, LegendMarkerSize -> Large];Legended[GeoGraphics[{EdgeForm[Black], FaceForm[Orange], Polygon[Entity["AdministrativeDivision", {"California", "UnitedStates"}]], GrayLevel[.4], PointSize[0.0075], Point[locations], PointSize[0.04], Red, Point[unweighted], Blue, Point[weighted]}, GeoRange -> {{32, 43}, {-125, -114}}, ImageSize -> 350], Placed[legend, "Bottom"]]The top eight largest cities in Ohio:
cities = CityData[{Large, "Ohio"}]The central feature of the eight cities based on TravelDistance:
center = CentralFeature[cities, DistanceFunction -> TravelDistance]The sum of distances from the central feature to the other cities, based on TravelDistance:
Total[Table[TravelDistance[center, city], {city, cities}]]Draw the cities' locations (gray) and the central feature (red):
GeoGraphics[{EdgeForm[Black], FaceForm[Orange], Polygon[Entity["AdministrativeDivision", {"Ohio", "UnitedStates"}]], Red, TravelDirections[{center, #}, "TravelPath"]& /@ cities, GrayLevel[.4], PointSize[0.03], Point /@ cities, PointSize[0.03], Red, Point[center]}]Properties & Relations (5)
CentralFeature is a multivariate location measure:
pts = {{3, -5}, {2, -5}, {0, 2}, {-4, -3}, {-3, 2}, {-5, -5}, {-1, -5}, {-1, -5}, {5, -1}, {-3, 3}, {10, -1}, {8, -2}};Graphics[{PointSize[0.03], Orange, Point[pts]}]cf = CentralFeature[pts]Mean is also a location measure:
mean = Mean[pts]Visualize the data points with central feature and mean:
Graphics[{PointSize[0.03], Orange, Point[pts], Locator[cf], Blue, PointSize[.04], Point[mean], Gray, Text["Central Feature", cf - {0, .8}], Text["Mean", mean + {0, .8}]}, ImageSize -> 250]CentralFeature finds a point belonging to the data that minimizes the sum of distances:
data = {{1., 3.}, {4., 6.}, {9., 2.}, {5., 5.}, {7., -2.}};cf = CentralFeature[data]Compute the central feature directly from the definition:
sumofdists[x_, y_] := Total[Sqrt[Total[(Transpose[data] - {x, y}) ^ 2]]]{ind} = Ordering[sumofdists@@@data, 1];
data[[ind]]Visualize the sum of distances function together with the data points:
sumofdists = Total[Sqrt[Total[(Transpose[data] - {#1, #2}) ^ 2]]]&;
ContourPlot[sumofdists[x, y], {x, 0, 10}, {y, -3, 8}, Contours -> 10, PlotLegends -> Automatic, Epilog -> {PointSize[Large], Black, Point[data], Red, PointSize[Large], Point[cf], White, Text["Central Feature", cf - {0, 0.7}]}]CentralFeature is the same as Median with univariate data when the data length is odd:
data = RandomReal[1, 1001];CentralFeature[data] == Median[data]CentralFeature finds an element in the data that minimizes the sum of distances to other data points:
data = RandomVariate[NormalDistribution[], {10, 3}];MemberQ[data, CentralFeature[data]]SpatialMedian finds a point in the domain that minimizes the sum of distances:
MemberQ[data, SpatialMedian[data]]The sum of distances with respect to CentralFeature is greater than or equal to the one with respect to SpatialMedian:
sumofdists = Total[Sqrt[Total[(Transpose[data] - #) ^ 2]]]&;sumofdists[CentralFeature[data]] ≥ sumofdists[SpatialMedian[data]]Create a random graph with edge weights sampled uniformly between 0 and 1:
SeedRandom[7];
graph = RandomGraph[{10, 15}, EdgeWeight -> RandomReal[1, 15]]Locate the GraphCenter:
GraphCenter[graph]Specify the distance between each pair of vertices using GraphDistance:
distfun = GraphDistance[graph, #1, #2]&;Locate the center using CentralFeature:
CentralFeature[Range[10], DistanceFunction -> distfun]Possible Issues (1)
CentralFeature of a non-weighted, two-element list returns the first element:
data = {GeoPosition[{20, -30}], GeoPosition[{15, 15}]};CentralFeature[data]For weighted two-element lists, it chooses the element with the highest weight, which trivially minimizes
:
CentralFeature[WeightedData[data, {1, 2}]]History
Text
Wolfram Research (2017), CentralFeature, Wolfram Language function, https://reference.wolfram.com/language/ref/CentralFeature.html.
CMS
Wolfram Language. 2017. "CentralFeature." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/CentralFeature.html.
APA
Wolfram Language. (2017). CentralFeature. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/CentralFeature.html
BibTeX
@misc{reference.wolfram_2026_centralfeature, author="Wolfram Research", title="{CentralFeature}", year="2017", howpublished="\url{https://reference.wolfram.com/language/ref/CentralFeature.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_centralfeature, organization={Wolfram Research}, title={CentralFeature}, year={2017}, url={https://reference.wolfram.com/language/ref/CentralFeature.html}, note=[Accessed: 13-June-2026]}