The L1 Median (Weber 1909)

The L1 Median (Weber 1909) 链接网址

Derived from a transportation cost minimization problem, the L1 median is defined to be any point which minimizes the sum of Euclidean distances to all points in the data set (fig.2).

As with most median definitions, the L1 median need not be one of the data. However, it is known to be a unique point in 2D or higher. The L1 is well known to reduce to the standard univariate median. Another similarity is that any measurement X of the data set can be moved along the vector from L1 to X without changing the value of the median. The breakdown point of the L1 median has been found to be 1/2. This is evident by noticing that if we place just over 50% of the data at one point, then the median will always stay there (fig.3). This idea can be extended to any data set within a bounded region: when just under 50% of the data is moved to infinity, the median remains in the vicinity of the majority of the data, since the bounded region resembles a point from infinity.

At present I am not aware of any solutions for finding the L1 median.

 

http://cgm.cs.mcgill.ca/~athens/Geometric-Estimators/location.html

转载于:https://www.cnblogs.com/yhlx125/p/5049069.html

### 中位数算法及其嵌套应用 #### 计算中位数的方法 对于一组数值数据,中位数是指将这些数值按大小顺序排列后位于中间位置的值。如果数值的数量是奇数,则中位数正好处于序列中央;如果是偶数,则取两个最中间数值的平均值作为中位数。 在实际编程实践中,可以利用NumPy库来简化这一过程,因为该库能够提供高效的数组处理能力以及内置函数median()用于直接获取给定数组的中位数值[^1]: ```python import numpy as np data = [7, 5, 3, 9, 8, 6, 4] # 使用numpy计算中位数 median_value = np.median(data) print(f"The median of the data is {median_value}") ``` #### 中位数在算法中的作用 中位数作为一种统计量,在数据分析和机器学习等领域有着广泛应用。相比于均值而言,中位数更能抵抗异常点的影响,因此常被用来评估中心趋势或者构建鲁棒性强的模型。例如,在图像处理过程中去除噪声时,可以通过计算局部窗口内的像素灰度级分布情况下的中位数来进行滤波操作。 另外值得注意的是,虽然这里讨论的重点在于一维数据集上的简单中位数运算,但在某些情况下也可能涉及到更高维度的数据结构或是更为复杂的业务逻辑下对多个子集中各自中位数的操作需求。此时就需要考虑如何合理运用循环、条件判断甚至是递归来完成任务了[^2]。 #### 复杂场景下的中位数计算实例 考虑到可能存在多层嵌套列表表示不同类别样本集合的情形,下面给出一段示范代码展示怎样遍历这样的复合型容器对象,并分别求得各组内部成员对应的中位数结果: ```python from statistics import median nested_lists = [ [10, 20, 30], [40, 50, 60, 70], [[80], [90]] ] def get_medians(nested_list): medians = [] for sublist in nested_list: try: # 如果当前项是一个纯数字列表,则直接计算其中位数 m = median(sublist) medians.append(m) except TypeError: # 否则认为遇到了更深一层的嵌套,递归调用本函数继续深入解析 deeper_medians = get_medians(sublist) overall_median = median(deeper_medians) medians.append(overall_median) return medians result = get_medians(nested_lists) print(result) ``` 此段代码通过引入`statistics`模块里的`median()`函数实现了针对任意深度嵌套列表元素间相互关系的有效分析与处理机制。同时借助于try-except语句捕获可能发生的类型错误从而触发进一步层次探索动作,最终达到预期目的即返回各个独立分组里边所含有的全部观测值之总体代表性指标——中位数。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值