计算 Mathematica 中每组的磁头数 [英] Count the number of heads per set in Mathematica

查看:33
本文介绍了计算 Mathematica 中每组的磁头数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先感谢大家的回复.我正在尽我最大的努力跟上所有的建议.但是我正在努力保持正轨.

First of all, thank you for all your responces. I am doing my best to keep up with all the suggestions. However I'm trying to stay on track.

所以现在我有

s = Table[RandomChoice[{Heads, Tails}, 2 i + 1], {i, 10}];

接下来,我想计算每个i"出现的Heads"的数量.

Next, I want to count the number of "Heads" that occur for each "i".

我可以为一个案例做到这一点....说 5,

I can do this for one case....say 5,

n = RandomChoice[{Heads, Tails}, 5];
n1 = Count[n, Heads];

但是我无法扩展它....

But I am having trouble expanding this....

再次感谢.

附言什么是投反对票?太简单了?

p.s. what are down votes? Too easy?

推荐答案

Map (/@) 统计列表中人头数的功能:

Map (/@) the function of counting heads in a list:

Count[#, Heads]&

s中的每个子列表.因此:

to each sublist in s. Hence:

Count[#, Heads]& /@ s

这篇关于计算 Mathematica 中每组的磁头数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆