在php中用小数据生成不同的钟形曲线

发布于 2025-01-03 23:49:52 字数 307 浏览 5 评论 0原文

我希望能够从很少的数据生成这些钟形曲线:

bell cuves

我正在寻找 php 中的函数这将为我提供这些钟形曲线生成的数据。我还不知道用什么来显示它们,但我首先需要数据。

我不太擅长数学,我尝试过创建一些正态分布,但没有一种简单的方法可以说:“我想要一条细钟形曲线”或“我想要一条大钟形曲线”。

也许使用上图右侧顶部的参数可能会很酷。

有人知道我如何在 PHP 中重现这些图表的数据点吗?

谢谢你!

I would like to be able to generate these bellcurves from very little data:

bell cuves

I'm looking for a function in php that would give me the data generated by these bell curves. I don't know yet what I'm going to use to display them, but I need the data first.

I'm not very good at math, I've tried creating some normal distribution, but there isn't an easy way to say: "I want a thin bell curve" or "I want a large one".

Maybe using the arguments that are on top of the right side of the picture above might be cool.

Would someone know how I can reproduce the datapoints of these graphs in PHP ?

Thank you!

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

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

发布评论

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

评论(1

栖迟 2025-01-10 23:49:52

嗯,你可以在维基百科上查找正态分布概率密度的公式

该函数的 PHP 实现如下所示:

function normal($x, $mu, $sigma) {
    return exp(-0.5 * ($x - $mu) * ($x - $mu) / ($sigma*$sigma))
        / ($sigma * sqrt(2.0 * M_PI));
}

该函数将为您提供您发布的钟形曲线的值。
我真的建议你阅读有关该函数的维基百科文章,但简单来说,$mu 标记了钟形曲线中心峰值的位置,而 $sigma 则确定了它的中心峰值位置。宽度($sigma 的值越大意味着分布越宽)。

Well, you could look up the formula of the normal distribution's probability density on Wikipedia.

A PHP implementation of this function would look like this:

function normal($x, $mu, $sigma) {
    return exp(-0.5 * ($x - $mu) * ($x - $mu) / ($sigma*$sigma))
        / ($sigma * sqrt(2.0 * M_PI));
}

This function will give you the value of the bell curves you posted.
I really suggest you read the Wikipedia article on the function, but to put it simply, $mu marks the position of the central peak of the bell curve and $sigma determines its width (a larger value for $sigma means a broader distribution).

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