~ubuntu-branches/ubuntu/trusty/gsl-ref-html/trusty

« back to all changes in this revision

Viewing changes to Quasi_002drandom-number-generator-examples.html

  • Committer: Bazaar Package Importer
  • Author(s): Dirk Eddelbuettel
  • Date: 2006-04-12 19:46:32 UTC
  • mfrom: (1.3.1 upstream) (3.1.1 dapper)
  • Revision ID: james.westby@ubuntu.com-20060412194632-c9lodpl075pv9si3
Tags: 1.8-1
* New upstream release 1.8
* As with previous releases, the sources were obtained from the FSF web 
  pages by means of a wget call (c.f. the debian/rules target 'upstream')

* debian/control: Standards-Version increased to 3.6.2
* debian/copyright: Updated FSF address
* debian/rules: Set DH_COMPAT=4

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<html lang="en">
 
2
<head>
 
3
<title>Quasi-random number generator examples - GNU Scientific Library -- Reference Manual</title>
 
4
<meta http-equiv="Content-Type" content="text/html">
 
5
<meta name="description" content="GNU Scientific Library -- Reference Manual">
 
6
<meta name="generator" content="makeinfo 4.8">
 
7
<link title="Top" rel="start" href="index.html#Top">
 
8
<link rel="up" href="Quasi_002dRandom-Sequences.html#Quasi_002dRandom-Sequences" title="Quasi-Random Sequences">
 
9
<link rel="prev" href="Quasi_002drandom-number-generator-algorithms.html#Quasi_002drandom-number-generator-algorithms" title="Quasi-random number generator algorithms">
 
10
<link rel="next" href="Quasi_002drandom-number-references.html#Quasi_002drandom-number-references" title="Quasi-random number references">
 
11
<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
 
12
<!--
 
13
Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 The GSL Team.
 
14
 
 
15
Permission is granted to copy, distribute and/or modify this document
 
16
under the terms of the GNU Free Documentation License, Version 1.2 or
 
17
any later version published by the Free Software Foundation; with the
 
18
Invariant Sections being ``GNU General Public License'' and ``Free Software
 
19
Needs Free Documentation'', the Front-Cover text being ``A GNU Manual'',
 
20
and with the Back-Cover Text being (a) (see below).  A copy of the
 
21
license is included in the section entitled ``GNU Free Documentation
 
22
License''.
 
23
 
 
24
(a) The Back-Cover Text is: ``You have freedom to copy and modify this
 
25
GNU Manual, like GNU software.''-->
 
26
<meta http-equiv="Content-Style-Type" content="text/css">
 
27
<style type="text/css"><!--
 
28
  pre.display { font-family:inherit }
 
29
  pre.format  { font-family:inherit }
 
30
  pre.smalldisplay { font-family:inherit; font-size:smaller }
 
31
  pre.smallformat  { font-family:inherit; font-size:smaller }
 
32
  pre.smallexample { font-size:smaller }
 
33
  pre.smalllisp    { font-size:smaller }
 
34
  span.sc    { font-variant:small-caps }
 
35
  span.roman { font-family:serif; font-weight:normal; } 
 
36
  span.sansserif { font-family:sans-serif; font-weight:normal; } 
 
37
--></style>
 
38
</head>
 
39
<body>
 
40
<div class="node">
 
41
<p>
 
42
<a name="Quasi-random-number-generator-examples"></a>
 
43
<a name="Quasi_002drandom-number-generator-examples"></a>
 
44
Next:&nbsp;<a rel="next" accesskey="n" href="Quasi_002drandom-number-references.html#Quasi_002drandom-number-references">Quasi-random number references</a>,
 
45
Previous:&nbsp;<a rel="previous" accesskey="p" href="Quasi_002drandom-number-generator-algorithms.html#Quasi_002drandom-number-generator-algorithms">Quasi-random number generator algorithms</a>,
 
46
Up:&nbsp;<a rel="up" accesskey="u" href="Quasi_002dRandom-Sequences.html#Quasi_002dRandom-Sequences">Quasi-Random Sequences</a>
 
47
<hr>
 
48
</div>
 
49
 
 
50
<h3 class="section">18.6 Examples</h3>
 
51
 
 
52
<p>The following program prints the first 1024 points of the 2-dimensional
 
53
Sobol sequence.
 
54
 
 
55
<pre class="example"><pre class="verbatim">     #include &lt;stdio.h>
 
56
     #include &lt;gsl/gsl_qrng.h>
 
57
     
 
58
     int
 
59
     main (void)
 
60
     {
 
61
       int i;
 
62
       gsl_qrng * q = gsl_qrng_alloc (gsl_qrng_sobol, 2);
 
63
     
 
64
       for (i = 0; i &lt; 1024; i++)
 
65
         {
 
66
           double v[2];
 
67
           gsl_qrng_get (q, v);
 
68
           printf ("%.5f %.5f\n", v[0], v[1]);
 
69
         }
 
70
     
 
71
       gsl_qrng_free (q);
 
72
       return 0;
 
73
     }
 
74
</pre></pre>
 
75
   <p class="noindent">Here is the output from the program,
 
76
 
 
77
<pre class="example">     $ ./a.out
 
78
     0.50000 0.50000
 
79
     0.75000 0.25000
 
80
     0.25000 0.75000
 
81
     0.37500 0.37500
 
82
     0.87500 0.87500
 
83
     0.62500 0.12500
 
84
     0.12500 0.62500
 
85
     ....
 
86
</pre>
 
87
   <p class="noindent">It can be seen that successive points progressively fill-in the spaces
 
88
between previous points.
 
89
 
 
90
   </body></html>
 
91