Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re^6: [OT] The statistics of hashing. (odd)

by tye (Sage)
on Apr 03, 2012 at 15:43 UTC ( [id://963269]=note: print w/replies, xml ) Need Help??


in reply to Re^5: [OT] The statistics of hashing.
in thread [OT] The statistics of hashing.

I suspect you need to start $toggle reversed for odd values (or for even values, though you note that you verified against the two even cases). Though, I would have expected that particular mistake to lead to negative values (but you don't show most of the code so I didn't go much further in looking). The numbers are supposed to be f(...)**$P where f() is positive (and monotonic), so, yes, odd values of $P should give you results between the results for $P-1 and $P+1, not like the results you posted.

Sorry for the wrapping.

You might want to put the big tables into READMORE tags so that they don't impact the rendering of the whole thread (though that should only happen for people who have code wrapping badly configured).

- tye        

Replies are listed 'Best First'.
Re^7: [OT] The statistics of hashing. (odd)
by BrowserUk (Patriarch) on Apr 03, 2012 at 16:07 UTC
    I suspect you need to start $toggle reversed for odd values

    Indeed. Using my $toggle = $P & 1 ? 1 : -1;, the output makes much more sense:

    C:\test>rbtcs-form-verify -H=16 -B=16 Using N x 2**16 vectors: 12 : 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 16 : 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 24 : 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 32 : 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 48 : 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 64 : 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 96 : 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 128 : 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 192 : 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 256 : 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 384 : 1 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 512 : 1 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 768 : 4 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 1024 : 7 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 1536 : 17 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 2048 : 31 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 3072 : 70 2 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 4096 : 125 5 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 6144 : 279 16 1 0 0 0 0 0 + 0 0 0 0 0 0 0 0 8192 : 491 38 3 0 0 0 0 0 + 0 0 0 0 0 0 0 0 12288 : 1083 125 16 2 0 0 0 0 + 0 0 0 0 0 0 0 0 16384 : 1887 284 47 8 1 0 0 0 + 0 0 0 0 0 0 0 0 24576 : 4082 877 209 53 13 3 1 0 + 0 0 0 0 0 0 0 0 32768 : 6981 1908 577 185 61 20 7 2 + 0 0 0 0 0 0 0 0 49152 : 14573 5450 2241 971 435 200 93 44 + 21 10 4 2 1 0 0 0 65536 : 24109 11016 5498 2882 1559 862 485 276 + 159 92 53 31 18 11 6 3
    you don't show most of the code so I didn't go much further in looking

    The entire code looks like this:

    #! perl -slw use strict; sub PTn { my @row; for( 1 .. shift ) { push @row, 1; $row [$_] += $row [$_ - 1] for reverse 1 .. @row - 2; } return @row; } sub expN { my( $P, $N, $X ) = @_; my $xDIVn = $X / $N; my @coefs = PTn( $P+1 ); my $rv = 0; my $toggle = $P & 1 ? 1 : -1; for my $p ( reverse 1 .. $P ) { $rv += $toggle * $coefs[ $p ] * $N / $p * exp( -$p * $xDIVn ); $toggle *= -1; } return $rv + $X; } our $H //= 10; our $B //= 32; print "Using N x 2**$B vectors:"; for my $inserts ( map{ 2**$_*3/4, 2**$_ } 4 .. $B ) { printf "%10d : ", $inserts; for my $h ( 1 .. $H ) { printf "%6d ", expN( $h, 2**$B, $inserts ) - expN( $h, 2**$B, +0 ); } print ''; }

    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.

    The start of some sanity?

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://963269]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (5)
As of 2024-03-28 21:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found