Math.random() 的大 O 估计?

发布于 2024-10-09 15:19:36 字数 40 浏览 0 评论 0原文

是否有可能获得 Math.random() 的 Big O 估计?

Is it possible to obtain a Big O estimate of Math.random()?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

简单爱 2024-10-16 15:19:36

我不确定这个问题是否有意义。没有可变大小的输入来增加仪表的复杂性 - 您进行调用(不带参数)并获得输出。

您是否询问 Math.random() 方法连续调用是否需要更长的时间?或者如果它只是比应有的速度慢?

请记住,即使复杂度为 O(1) 的算法也可能需要很长时间 - 只是它们花费的时间长度并不取决于涉及的数据量。

I'm not sure this question makes much sense. There's no variable size input to increase gauge complexity against - you make a call (with no arguments) and you get an output.

Are you asking if the Math.random() method takes longer for successive calls? Or if it's just slower than it should be?

Remember that even algorithms with O(1) complexity can take a long time - it's just that the length of time they take doesn't depend on how much data is involved.

不念旧人 2024-10-16 15:19:36

该算法已记录,请参阅此处 。这是一个线性同余生成器,最终复杂度为 O(1)

The algorithm is documented, see here. It's a Linear congruential generator which ends up having complexity of O(1)

空心空情空意 2024-10-16 15:19:36

它肯定是..只需看看该函数在库中是如何实现的,然后应用递归方程并做一些数学计算。 ;)

it definitely is.. just look at how the function is implemented in the library and then apply recurrence-equations and do some math. ;)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文