算法与发现概率概率、算法、发现

2023-09-11 07:27:06 作者:丶Heart、以心换心

这是不是一个homwork 它的一个问题,我遇到了一个编程比赛,但无法找到一个解决的办法。

this is not a homwork its a problem i came across in a programming contest but could not find a solution to it.

Byteland王国包含编号为1..N n个城市。对于每一个城市的我,国王指派一些钱,这个城市为它的年度检修。分配是随机选择艾之间的量(所需的该城市的最小量),和双(可分配给该城市的最大数量)。需要注意的是分配给城市的数量不必是整数。今年收集的总税额为C。

The kingdom of Byteland contains N cities numbered 1..N. For each city i, the king assigns some money to that city for it's annual maintenance. The amount assigned is chosen randomly between ai (the minimum amount needed by that city), and bi (the maximum amount that can be assigned to that city). Note that the amount assigned to a city need not be an integer. The total tax collected this year is C.

什么是该国今年将发出亏损的概率

What is the probability that the kingdom will issue a loss this year

推荐答案

我想这是正确的说法:

Byteland王国包含编号为1..N n个城市。对于每一个城市的我,国王指派一些钱,这个城市为它的年度检修。分配是随机选择艾之间的量(所需的该城市的最小量),和双(可分配给该城市的最大数量)。需要注意的是分配给城市的数量不必是整数。今年收集的总税额为C。

The kingdom of Byteland contains N cities numbered 1..N. For each city i, the king assigns some money to that city for it's annual maintenance. The amount assigned is chosen randomly between ai (the minimum amount needed by that city), and bi (the maximum amount that can be assigned to that city). Note that the amount assigned to a city need not be an integer. The total tax collected this year is C.

什么是该国今年将发出亏损的概率是多少?换句话说,什么是分配给所有城市的总金额超过了收集到的总税收的概率是多少?

What is the probability that the kingdom will issue a loss this year? In other words, what is the probability that the total amount assigned to all cities exceeds the total tax collected?

所有分配的总和为X_0 + ... x_i + ... x_n 如果U(A,B)是a和b之间的均匀数 所有的赋值u的总和(0,B_0 - A_0)+ A_0 + ... + U(0,b_i - A_I)+ A_I + ... + U(0,B_N - A_N)+ A_N 其等于A_0 + ... A_I + ... A_N + U(0,B_0 - A_0)+ ... + U(0,b_i - A_I)+ ... + U(0,B_N - 一个) 所有的值是已知的。该公式将均匀分布也是已知的(检查这里):但是在编程问题,你不要'T需要使用的分析解决方案,但实现的东西,给你一个好足够数量...你应该使用蒙特卡罗或类似的东西来模拟概率...你也可以使用一个事实,即U(0,K )= K * U(0,1)。要计算的总和的不同值的概率,然后将它们进行比较到C

the sum of all assignment is x_0 + ... + x_i + ... + x_n If U(a,b) is a uniform number between a and b the sum of all assignment U(0, b_0 - a_0) + a_0 + ... + U(0, b_i - a_i) + a_i + ... + U(0, b_n - a_n) + a_n which is equal to a_0 + ... + a_i + ... + a_n + U(0, b_0 - a_0) + ... + U(0, b_i - a_i) + ... + U(0, b_n - a_n) all the values are known. The formula for adding uniform distributions is also known (check here): but in the programming problem you don't need to use the analytical solution, but implement something that gives you a good enough number... You should use montecarlo or something like that to simulate the probabilities... And you could also use the fact that U(0, k) = k * U(0, 1). To calculate the probability of the different values of the sum, and then compare them to C.