本文整理汇总了C++中Format::FormatType方法的典型用法代码示例。如果您正苦于以下问题:C++ Format::FormatType方法的具体用法?C++ Format::FormatType怎么用?C++ Format::FormatType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Format
的用法示例。
在下文中一共展示了Format::FormatType方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: test1
void test1(int n)
{
Normal nn;
Uniform uniform;
cout <<
"Print 20 N(0,1) random numbers - should be the same as in sample output" <<
endl;
{
Format F; F.FormatType(Format::DEC_FIGS); F.Precision(12); F.Width(15);
for (int i=0; i<20; i++) cout << F << nn.Next() << endl;
}
cout << endl;
cout << "Print histograms of data from a variety distributions" << endl;
cout << "Histograms should be close to those in sample output" << endl;
cout << "s. mean and s. var should be close to p. mean and s. mean" << endl << endl;
{ Constant c(5.0); Histogram(&c, n); }
{ Uniform u; Histogram(&u, n); }
{ SumRandom sr=uniform(3)-1.5; Histogram(&sr, n); }
{ SumRandom sr=uniform-uniform; Histogram(&sr, n); }
{ Normal normal; Histogram(&normal, n); }
{ Cauchy cauchy; Histogram(&cauchy, n); }
{ AsymGenX normal10(NORMAL10, 10.0); Histogram(&normal10, n); }
cout << "Mean and variance should be 10.0 and 4.0" << endl;
{ AsymGenX uniform2(UNIF,0.5); Histogram(&uniform2, n); }
cout << "Mean and variance should be 0.5 and 0.083333" << endl;
{ SymGenX triang(TRIANG); Histogram(&triang, n); }
cout << "Mean and variance should be 0 and 0.16667" << endl;
{ Poisson p(0.25); Histogram(&p, n); }
{ Poisson p(10.0); Histogram(&p, n); }
{ Poisson p(16.0); Histogram(&p, n); }
{ Binomial b(18,0.3); Histogram(&b, n); }
{ Binomial b(19,0.3); Histogram(&b, n); }
{ Binomial b(20,0.3); Histogram(&b, n); }
{ Binomial b(58,0.3); Histogram(&b, n); }
{ Binomial b(59,0.3); Histogram(&b, n); }
{ Binomial b(60,0.3); Histogram(&b, n); }
{ Binomial b(18,0.05); Histogram(&b, n); }
{ Binomial b(19,0.05); Histogram(&b, n); }
{ Binomial b(20,0.05); Histogram(&b, n); }
{ Binomial b(98,0.01); Histogram(&b, n); }
{ Binomial b(99,0.01); Histogram(&b, n); }
{ Binomial b(100,0.01); Histogram(&b, n); }
{ Binomial b(18,0.95); Histogram(&b, n); }
{ Binomial b(19,0.95); Histogram(&b, n); }
{ Binomial b(20,0.95); Histogram(&b, n); }
{ Binomial b(98,0.99); Histogram(&b, n); }
{ Binomial b(99,0.99); Histogram(&b, n); }
{ Binomial b(100,0.99); Histogram(&b, n); }
{ NegativeBinomial nb(100,6.0); Histogram(&nb, n); }
{ NegativeBinomial nb(11,9.0); Histogram(&nb, n); }
{ NegativeBinomial nb(11,1.9); Histogram(&nb, n); }
{ NegativeBinomial nb(11,0.10); Histogram(&nb, n); }
{ NegativeBinomial nb(1.5,1.9); Histogram(&nb, n); }
{ NegativeBinomial nb(1.0,1.9); Histogram(&nb, n); }
{ NegativeBinomial nb(0.3,19); Histogram(&nb, n); }
{ NegativeBinomial nb(0.3,1.9); Histogram(&nb, n); }
{ NegativeBinomial nb(0.3,0.05); Histogram(&nb, n); }
{ NegativeBinomial nb(100.8,0.18); Histogram(&nb, n); }
{ ChiSq c(1,2.0); Histogram(&c, n); }
{ ChiSq c(2,2.0); Histogram(&c, n); }
{ ChiSq c(3,2.0); Histogram(&c, n); }
{ ChiSq c(4,2.0); Histogram(&c, n); }
{ ChiSq c(1 ); Histogram(&c, n); }
{ ChiSq c(2 ); Histogram(&c, n); }
{ ChiSq c(3 ); Histogram(&c, n); }
{ ChiSq c(4 ); Histogram(&c, n); }
{ Gamma g1(1.0); Histogram(&g1, n); }
{ Gamma g2(0.5); Histogram(&g2, n); }
{ Gamma g3(1.01); Histogram(&g3, n); }
{ Gamma g4(2.0); Histogram(&g4, n); }
{ Pareto p1(0.5); Histogram(&p1, n); }
{ Pareto p2(1.5); Histogram(&p2, n); }
{ Pareto p3(2.5); Histogram(&p3, n); }
{ Pareto p4(4.5); Histogram(&p4, n); }
Real probs[]={.1,.3,.05,.11,.05,.04,.05,.05,.1,.15};
Real val[]={2,3,4,6,8,12,16,24,32,48};
{ DiscreteGen discrete(10,probs); Histogram(&discrete, n); }
{ DiscreteGen discrete(10,probs,val); Histogram(&discrete, n); }
}