BinLists
更多信息
- BinLists 会去掉值与实数不一致的元素.
- 可以给出以下箱宽规格 binspec:
-
dx 宽度为 dx 的分箱 » {xmin,xmax,dx} 从 xmin 到 xmax 的区间内宽度为 dx 的分箱 » {{b1,b2,…}} 区间 [b1,b2), [b2,b3), … » xbins,ybins,… 多变量 data 的分箱规格可理解为 {{x1,y1,…},{x2,y2, …},…} » - BinCounts[data,dx] 使箱边界为 dx 的整数倍数,第一个箱始于 Ceiling[Min[data]-dx,dx],最后一个箱结束于 Floor[Max[data]+dx,dx] 处.
-
- BinLists[data] 等价于 BinLists[data,1].
- 在 BinLists[data,{xmin,xmax,dx}] 中,当元素的值满足
时,会被放入分箱 i 中. -
- BinLists[data,{xmin,xmax}] 等价于 BinLists[data,{xmin,xmax,1}].
- 在 BinLists[data,{{b1,b2,…}}] 中,满足
的元素置于箱 i 中. -
- 在 BinLists[data,{{b1,b2,…}}] 的形式下,各结尾处的 bi 可以是 -Infinity 和 +Infinity.
- 如果 bi 没有形成递增序列,它们由 BinLists 自动排序.
- 如果 data 由长度为 n 的子列表构成,则必须给出 n 个箱的指定,BinLists[data,…] 产生一个深度 n 的列表阵列.
- 在每个箱中,元素出现的顺序与原始数据中相同.
- data 可以有以下形式和解释:
-
{x1,x2,…} 实数和量的列表 » {{x1,y1,…},{x2,y2,…},…} 同维度向量列表 » SparseArray 等价于 Normal[data] 的数组 » QuantityArray 列兼容量的数组 » TimeSeries, TemporalData,… 值的向量或数组(时间戳忽略不计) » - 输入元素 xi 的标签 inds 可以用以下格式给出: »
-
{x1,x2,…} 使用 xi 自身(默认无标签) {x1,x2,…}Automatic 使用整数标签 {x1,x2,…}{v1,v2,…} 所有元素和所有标签之间的规则 {x1v1,x2v2,…} 元素 xi 与其标签 vi 之间的规则列表
范例
打开所有单元 关闭所有单元基本范例 (3)
范围 (12)
基础用法 (8)
data = Table[Mod[i ^ 2, {3, 5}], {i, 20}];
Dimensions[data]BinLists[data, 1, 1]data = RandomReal[{-1, 1}, {10, 2}];
Dimensions[data]BinLists[data, {-1, 1, .25}, {-1, 1, .25}]data = RandomReal[{-1, 1}, {10, 2}];BinLists[data, {{-2, .3, 2}}, {{-1, -.4, .2, 1}}]BinLists[RandomReal[{-1, 1}, {10, 4}]]BinLists[{1.5, 3, a, 2.5, 1, I}, 2]BinLists[{1.5, 3, N[3, 20], 2.5, 1, E}, 2]SparseArray 数据可以像稠密数组一样使用:
data = SparseArray[{{1, 1} -> 5, {3, 2} -> 4}, {30, 2}]BinLists[data]sp = SparseArray[{{i_, i_} :> i, {i_, j_} /; j == i + 1 :> i - 1}, {10, 3}, 3]BinLists[sp]ts = TemporalData[TimeSeries, {{{-0.8514215942160073, 0.498847153572056, -0.5117595526567502,
-0.1541269987967291, 0.21199829846035145, 0.7834143496676975, -0.16460155429334833,
0.8166857502105551, -0.662728145444706, -0.9440223497598601, 0.34 ... 0.12583411201016714}},
{TemporalData`DateSpecification[{2014, 2, 2, 0, 0, 0.}, {2014, 2, 14, 0, 0, 0.}, {1, "Day"}]}, 1,
{"Continuous", 1}, {"Discrete", 1}, 1,
{ResamplingMethod -> {"Interpolation", InterpolationOrder -> 1}}}, True, 10.1];BinLists[ts]BinLists[ts["Values"]]% == %%带有量的数据 (3)
data = {Quantity[-1.541, "Grams"], Quantity[-0.849, "Grams"], Quantity[-0.477, "Grams"], Quantity[-0.133, "Grams"], Quantity[-0.11, "Grams"], Quantity[-0.054, "Grams"], Quantity[0.226, "Grams"], Quantity[0.259, "Grams"], Quantity[1.4, "Grams"], Quantity[1.661, "Grams"]};BinLists[data]BinLists[data, Quantity[.5, "Grams"]]BinLists[data, {Quantity[-1, "Grams"], Quantity[1, "Grams"], Quantity[.1, "Grams"]}]BinLists[data, {{Quantity[-2, "Grams"], Quantity[0, "Grams"], Quantity[2, "Grams"]}}]mat = RandomReal[10, {3, 3}];
mat[[All, 1]] *= Quantity["Meters"];
mat[[All, 3]] *= Quantity["Seconds"];mat//MatrixFormBinLists[mat, Quantity[2, "Meters"], 3, Quantity[1, "Seconds"]]QuantityArray 可像数组一样使用:
data = QuantityArray[RandomReal[1, 6], "Pounds"]BinLists[data]BinLists[data, Quantity[.2, "Kilograms"]]带标签的数据 (1)
应用 (1)
属性和关系 (1)
data = RandomReal[{-5, 5}, 1000];Map[Length, BinLists[data]]BinCounts[data]%% == %data2 = RandomReal[{-5, 5}, {1000, 2}];Map[Length, BinLists[data2], {2}] == BinCounts[data2]可能存在的问题 (4)
BinLists[{1, 2, 3, 4, 5}]BinLists[{1 - $MachineEpsilon, 2, 3, 4, 5}]data = Quantity[RandomReal[1, 20], "Meters"];BinLists[data, .2]BinLists[data, Quantity[20, "Centimeters"]]mat = {{Quantity[1.03, "Meters"], Quantity[1.65, "Meters"], Quantity[1.49, "Meters"]}, {4.013, 3.40, 2.5}, {Quantity[3.9, "Seconds"], Quantity[1.88, "Seconds"], Quantity[3.52, "Seconds"]}};BinLists[mat]BinLists[Transpose@mat]使用 {min,max,dx} 规格得到的分箱可能不包括所有数据点:
data = Range[1, 50];res1 = BinLists[data, {Min[data], Max[data], 10}]{Length[data], Total[Length /@ res1]}指定 min 和 max,以便将所有数据点都纳入分箱覆盖范围:
dx = 10;
min = 1;
max = min + dx * Ceiling[Length[data] / dx];res2 = BinLists[data, {min, max, dx}]Total[Length /@ res2]res3 = BinLists[data, 10]Total[Length /@ res3]文本
Wolfram Research (2007),BinLists,Wolfram 语言函数,https://reference.wolfram.com/language/ref/BinLists.html (更新于 2024 年).
CMS
Wolfram 语言. 2007. "BinLists." Wolfram 语言与系统参考资料中心. Wolfram Research. 最新版本 2024. https://reference.wolfram.com/language/ref/BinLists.html.
APA
Wolfram 语言. (2007). BinLists. Wolfram 语言与系统参考资料中心. 追溯自 https://reference.wolfram.com/language/ref/BinLists.html 年
BibTeX
@misc{reference.wolfram_2026_binlists, author="Wolfram Research", title="{BinLists}", year="2024", howpublished="\url{https://reference.wolfram.com/language/ref/BinLists.html}", note=[Accessed: 12-August-2026]}
BibLaTeX
@online{reference.wolfram_2026_binlists, organization={Wolfram Research}, title={BinLists}, year={2024}, url={https://reference.wolfram.com/language/ref/BinLists.html}, note=[Accessed: 12-August-2026]}