████[資料刪除]
這道題研究的是連續型變數,那麼為了描述它在各個數值的概率,我們可以用概率密度函式來描述。那啥是概率密度函式啊?
看度娘給我們的解釋:
容易知道p(x
≤a)=
∫0ap
(x)p(x\leq a)=\int_0^ap(x)
p(x≤a)
=∫0a
p(x
),那p(x
≥a)p(x\geq a)
p(x≥a)
怎麼辦?看看度娘給的第二條性質,那麼就有p(x
≥a)=
1−∫0
ap(x
)p(x\geq a)=1-\int_0^ap(x)
p(x≥a)
=1−∫
0ap
(x)。
那我們來考慮第乙個操作對的概率的影響,應該就是
h (x
)=f(
x)(1
−∫0x
g(x)
dx)+
g(x)
(1−∫
0xf(
x)dx
)h(x)=f(x)(1-\int_0^xg(x)dx)+g(x)(1-\int_0^xf(x)dx)
h(x)=f
(x)(
1−∫0
xg(
x)dx
)+g(
x)(1
−∫0x
f(x
)dx)
同樣的我們考慮第二個:
h (x
)=f(
x)∫0
xg(x
)dx+
g(x)
∫0xf
(x)d
xh(x)=f(x)\int_0^xg(x)dx+g(x)\int_0^xf(x)dx
h(x)=f
(x)∫
0xg
(x)d
x+g(
x)∫0
xf(
x)dx
那麼我們維護概率密度函式即可。不知道為什麼積分後的函式各項係數還是整數,反正用ll存我們就可以在中間計算時避免精度誤差了。
由期望的計算式就有e=∑
p(x)
xe=\sum p(x)x
e=∑p(x
)x,所以ans
=∫01
xf(x
)dxans=\int_0^1xf(x)dx
ans=∫0
1xf
(x)d
x 注意精度問題。由於double在變數整數部分較大的時候小數部分精度損失嚴重,我們不妨直接取其小數部分。
#include
#include
#include
#include
#include
#define rg register
using
namespace std;
typedef
long
long ll;
const
int maxn=
101;
template
<
typename tp>
inline
intgetmin
(tp &x,tp y)
template
<
typename tp>
inline
intgetmax
(tp &x,tp y)
template
<
typename tp>
inline
void
read
(tp &x)
struct poly
poly operator+(
const poly &b)
const
poly operator-(
const poly &b)
const
poly operator*(
const poly &b)
const
poly inte()
}a,b,fa,fb,st,tmp,sk[
100]
;int tp,tk,stk[
100]
;long
double ans;
char s[
10010];
intmain()
else}}
sk[1]
=sk[1]
*tmp;
for(rg int i=sk[1]
.deg;i;i--
)printf
("%.6lf\n"
,ans);}
return0;
}
實現計算器
dim boldot as boolean dim dblacc1,dblacc2 as double dim dblacc3 as double 10 dim strop as string private sub add num byval intnumber as integer if bol...
計算器修改
在做計算器介面修改這個專案中遇見的問題。先把需求說清楚,黑莓風格的計算器裡面有觸控和非觸控兩個流程。介面,功能,和座標是不一樣的。我是要在非觸控下做出觸控螢幕的介面,除了不能觸控以外,所有的功能都要和觸控螢幕下一樣。之前先是找到資源,然後替換資源,載入,調座標,調功能,調bug。資源很快就找到了,然...
簡單計算器
unit unit1 inte ce uses windows,messages,sysutils,variants,classes,graphics,controls,forms,dialogs,stdctrls,buttons,math math是數 算單元 type tform1 class ...