根据连续分布产生随机数一般方法

/this program generates random number according to //the continues distributionauther :HuiLi 3/16/2016 00:59/void f1(){double F,A;auto h1=new TH1D("continuent","A;x_{t};count",1000,0,1);auto h2=new TH1D("h2","A;x_{t};count",1000,0,1);TRandom3 r;double t;for (int i=0;i<100000 i="" f="pow(r.Uniform(),2)*0.5;" t="pow(2*F,1.0/2);" h1-="">Fill(t);}归一化normalization//for(i=1;i<=1000;i++){ A=1./1000*(h1->GetBinContent(i));h2->SetBinContent(i,A);} auto c1 =new TCanvas(); c1->Divide(1,2); c1->cd(1); h1->Draw(); h1->Scale();//h1->Draw(); c1->cd(2); h2->Draw();}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值