DiscreteIndicator[x,x1,{u1,u2,…}]
生成离散指示函数,如果 x=x1,它等于 1,否则如果对于某些 i 有 x=ui,它等于 0.
DiscreteIndicator
DiscreteIndicator[x,x1,{u1,u2,…}]
生成离散指示函数,如果 x=x1,它等于 1,否则如果对于某些 i 有 x=ui,它等于 0.
更多信息
- 如果 x 或 x1 不是任何一个 ui,DiscreteIndicator[x,x1,{u1,u2,…}] 保持未计算的形式. »
范例
打开所有单元 关闭所有单元基本范例 (1)
应用 (1)
lm = LinearModelFit[{{a, 1.5}, {b, 2.3}, {b, 1.8}, {a, 2.5}}, x, x, NominalVariables -> x]Normal[lm]在点 a 和 b,计算 FittedModel:
{lm[a], lm[b]}属性和关系 (2)
当两个值都在集合中,DiscreteIndicator 等价于 Boole:
Table[{DiscreteIndicator[x, a, {a, b, c}], Boole[x === a]}, {x, {a, b, c}}]{DiscreteIndicator[x, a, {a, b, c}], Boole[x === a]}Flatten[Table[{{x, y},
DiscreteIndicator[x, a, {a, b}]DiscreteIndicator[y, b, {a, b}], DiscreteIndicator[{x, y}, {a, b}, {{a, a}, {a, b}, {b, a}, {b, b}}]}, {x, {a, b}}, {y, {a, b}}], 1] //Grid文本
Wolfram Research (2008),DiscreteIndicator,Wolfram 语言函数,https://reference.wolfram.com/language/ref/DiscreteIndicator.html.
CMS
Wolfram 语言. 2008. "DiscreteIndicator." Wolfram 语言与系统参考资料中心. Wolfram Research. https://reference.wolfram.com/language/ref/DiscreteIndicator.html.
APA
Wolfram 语言. (2008). DiscreteIndicator. Wolfram 语言与系统参考资料中心. 追溯自 https://reference.wolfram.com/language/ref/DiscreteIndicator.html 年
BibTeX
@misc{reference.wolfram_2026_discreteindicator, author="Wolfram Research", title="{DiscreteIndicator}", year="2008", howpublished="\url{https://reference.wolfram.com/language/ref/DiscreteIndicator.html}", note=[Accessed: 13-September-2026]}
BibLaTeX
@online{reference.wolfram_2026_discreteindicator, organization={Wolfram Research}, title={DiscreteIndicator}, year={2008}, url={https://reference.wolfram.com/language/ref/DiscreteIndicator.html}, note=[Accessed: 13-September-2026]}