Talk:Van der Corput sequence: Difference between revisions

From Rosetta Code
Content added Content deleted
m (→‎displaying of terms: added whitespace.)
 
(5 intermediate revisions by 3 users not shown)
Line 1: Line 1:
__TOC__


== Python output ==
== Python output ==
Looks to me like the base 2 sample output for the Python example is actually base 3?--[[User:Tikkanz|Tikkanz]] 08:34, 11 March 2011 (UTC)
Looks to me like the base 2 sample output for the Python example is actually base 3?--[[User:Tikkanz|Tikkanz]] 08:34, 11 March 2011 (UTC)
: Umm, my (very good) maths teachers defence in such situations was to say "Excellent lad, you've found the deliberate mistake"! :-)
: Umm, my (very good) maths teachers defence in such situations was to say "Excellent lad, you've found the deliberate mistake"! :-)
: I'm at work at the moment but will correct the copy/paste error this evening. Thanks, --[[User:Paddy3118|Paddy3118]] 09:53, 11 March 2011 (UTC)
: I'm at work at the moment but will correct the copy/paste error this evening. Thanks, --[[User:Paddy3118|Paddy3118]] 09:53, 11 March 2011 (UTC)
: Hmm? The text says base 3, numbers do look like base 2. Edit conflict? --[[User:Ledrug|Ledrug]] 07:03, 10 June 2011 (UTC)

== displaying of terms ==

In every reference I've looked at, the 2nd term of the van der Corput sequence (for base two) is
'''.1'''
(not) '''.10000000'''
<br><br>I suggest that trailing zeroes illegitimatizes the terms.

Mathematically, of course, &nbsp; '''.1''' &nbsp; is equal to &nbsp; '''.100''' &nbsp; (except to an engineer, where trailing zeroes signify more precision). &nbsp; &nbsp; -- [[User:Gerard Schildberger|Gerard Schildberger]] 03:28, 26 March 2012 (UTC)

==Generation of the image in the task description==
My windows machine has packed up so I am using Ipython on Ubuntu. I did the following to create the image:

<lang python>In [211]: from __future__ import division

In [212]: def vdc(n, base=2):
...: vdc, denom = 0,1
...: while n:
...: denom *= base
...: n, remainder = divmod(n, base)
...: vdc += remainder / denom
...: return vdc

In [213]: plt.plot([(random.random()*0.5, 0.5+vdc(i)*0.5) for i in range(2500)], '.')
Out[213]:
[<matplotlib.lines.Line2D at 0x12c73f2c>,
<matplotlib.lines.Line2D at 0x1311fe4c>]

In [214]: plt.title('Distribution: Van der Corput (top) vs pseudorandom')
Out[214]: <matplotlib.text.Text at 0x12ed6fcc>

In [215]: </lang>
--[[User:Paddy3118|Paddy3118]] 21:59, 7 August 2012 (UTC)

Latest revision as of 21:30, 4 October 2020


Python output

Looks to me like the base 2 sample output for the Python example is actually base 3?--Tikkanz 08:34, 11 March 2011 (UTC)

Umm, my (very good) maths teachers defence in such situations was to say "Excellent lad, you've found the deliberate mistake"! :-)
I'm at work at the moment but will correct the copy/paste error this evening. Thanks, --Paddy3118 09:53, 11 March 2011 (UTC)
Hmm? The text says base 3, numbers do look like base 2. Edit conflict? --Ledrug 07:03, 10 June 2011 (UTC)

displaying of terms

In every reference I've looked at, the 2nd term of the van der Corput sequence (for base two) is

            .1
   (not)    .10000000



I suggest that trailing zeroes illegitimatizes the terms.

Mathematically, of course,   .1   is equal to   .100   (except to an engineer, where trailing zeroes signify more precision).     -- Gerard Schildberger 03:28, 26 March 2012 (UTC)

Generation of the image in the task description

My windows machine has packed up so I am using Ipython on Ubuntu. I did the following to create the image:

<lang python>In [211]: from __future__ import division

In [212]: def vdc(n, base=2):

    ...:     vdc, denom = 0,1
    ...:     while n:
    ...:         denom *= base
    ...:         n, remainder = divmod(n, base)
    ...:         vdc += remainder / denom
    ...:     return vdc

In [213]: plt.plot([(random.random()*0.5, 0.5+vdc(i)*0.5) for i in range(2500)], '.') Out[213]: [<matplotlib.lines.Line2D at 0x12c73f2c>,

<matplotlib.lines.Line2D at 0x1311fe4c>]

In [214]: plt.title('Distribution: Van der Corput (top) vs pseudorandom') Out[214]: <matplotlib.text.Text at 0x12ed6fcc>

In [215]: </lang> --Paddy3118 21:59, 7 August 2012 (UTC)