Mathematica,增加 2n+1,而不是 3
这就是我所拥有的。
RandomChoice[{.5, .5} -> {Heads, Tails}, 3]
然后我写
RandomChoice[{.5, .5} -> {Heads, Tails}, 5]
如何以 2n+1 的增量增加这个函数?
Here's what I have.
RandomChoice[{.5, .5} -> {Heads, Tails}, 3]
then I write
RandomChoice[{.5, .5} -> {Heads, Tails}, 5]
How do I increase this function by increments of 2n+1?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我将您的请求解释为表明您想要函数 2n + 1,增量为 2。因此值将是:3、5、7、9、11...如果这是正确的解释,则以下内容应该有效:
因此,对于 {1,2,3,4,5,6,7,8,9,10} 的域, f(n) = 2 n + 1
方式获得相同的结果:
您可以通过以下 增量是2。但是它不是同一个函数。目标与之前相同,但域现在与目标集相同:{3, 5, 7...21}
I interpreted your request as indicating you wanted the function, 2n + 1, with increments of 2. So the values would be: 3, 5, 7, 9, 11...If that is the correct interpretation then the following should work:
So, f(n) = 2 n + 1 for the domain of {1,2,3,4,5,6,7,8,9,10}
You can achieve the same result with:
This makes it even clearer that the increment is 2. However it is not the same function. The target is the same as before but the domain is now the same as the target set: {3, 5, 7...21}
您正在寻找这样的东西吗?
这将给出一个示例输出:
这也做了同样的事情:
我不知道是否有更优雅/更有效的方法来做到这一点,因为我是 Mathematica 的新手 - 但我确信有人会评论如果有。
Is something like this what you're looking for?
Which would give a sample output of:
This also does the same thing:
I don't know if there is a more elegant/efficient way of doing this, since I'm new to Mathematica - but I'm sure someone will comment if there is.