对数分布

发布于 2024-10-06 04:50:18 字数 617 浏览 7 评论 0原文

首先,数学不是我的专长。

想象一个这样的问题:

我有很多钱要花,比如 500,并且我需要在固定的天数内花掉它们,比如 20。我每天有一个固定的最多花钱,比如 50。我一天不需要花钱。

现在我需要知道如何计算我每天必须花费的总金额才能获得如下所示的支出曲线:

 Curve

我的目标是一个需要一定数量的钱和天数的函数,并返回一个包含天数和当天的钱数的元组。

我知道我需要使用某种类型的对数,并且我已经尝试了我的大脑可以处理的几乎所有内容。我一直在查看 wolfram mathworld 和这个公式:

y = a + b ln x

但是它并没有真正帮助我。

PHP、Python 或 C# 的提示或示例会很棒,但任何语言都可以。

如果您需要更多信息或者问题含糊不清,请告诉我,我真的很想解决这个问题。谢谢你!

First of all, math is not my area.

Imagine a problem like this:

I have a number of money to spend, say 500, and i need to spend them on a fixed number of days, say 20. I have a fixed maximum of money to spend per day, like 50. I don't need to spend money on a day.

Now i need to know how to calculate the total number of money I have to spend each day to get a spending curve like the following:

Curve

My goal is a function that takes a number of money and a number of days, and returns an tuple with day number and ammount of money for that day.

I know i need to use logarithms of some type, and i've tried pretty much everything that my brain can handle. I've been looking at wolfram mathworld and this formula:

y = a + b ln x

But it does not really help me.

An hint or example in PHP, Python or C# would be great, but any language will do.

PLEASE let me know if you need any more information or if the question is vague, I really want to solve this. Thank you!

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

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

发布评论

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

评论(2

冰雪之触 2024-10-13 04:50:18

我不明白你为什么想要日志分布。抛物线即可获得您想要的曲线形式:

 spend[day] = a day^2 + c 

其中:

a -> (6 * (TD - TA)) / (TD *(-1 - 3 * TD + 4 * TD^2))  


c -> -((1 + 3 * TD - 6*TA*TD + 2 * TD^2)/ (-1 - 3 * TD + 4 * TD^2))  

TA = Total Amount
TD = Total Days

您最后一天花费的金额为 1。

对于您的示例值:(amt 500,第 20 天)

替代文本

I don't understand why you want a log distribution. A parabolic one will do to obtain the curve form you want:

 spend[day] = a day^2 + c 

where:

a -> (6 * (TD - TA)) / (TD *(-1 - 3 * TD + 4 * TD^2))  


c -> -((1 + 3 * TD - 6*TA*TD + 2 * TD^2)/ (-1 - 3 * TD + 4 * TD^2))  

TA = Total Amount
TD = Total Days

With this the amount you spend the last day is 1.

For your example values: (amt 500, days 20)

alt text

残月升风 2024-10-13 04:50:18

您确定您要求的不是线性方程吗?
例如
y=f(x)=-50x+500,总天数为 x,其中 y=0。

Are you sure what you are asking for is not a linear equation?
For example
y=f(x)=-50x+500 and the total number of days would be x where y=0.

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