Article View: pl.comp.programming
Article #217546Re: Jak zrobić test za pomocą PractRand?
From: M.M.
Date: Tue, 24 Aug 2021 09:46
Date: Tue, 24 Aug 2021 09:46
112 lines
7411 bytes
7411 bytes
On Tuesday, August 24, 2021 at 1:43:54 AM UTC+2, osobli...@gmail.com wrote:
> To też nie działa:
>
> def to_bytes(num, size):
> x = num if num >= 0 else 256**size + num
> h = hex(x)[2:].rstrip("L")
> return binascii.unhexlify("0"*((2*size)-len(h))+h)
>
> Wyniki, które otrzymuję są podobne do tego, który podano w przykładzie:
>
> \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
>
> Oznacza, to, że prawie na pewno konwertuję dane dobrze. Problem jest nadal z przekazaniem tego do PractRand. Nie wiem, czy używam poprawnie:
>
> sys.stdout.buffer.write(binary)
>
> Skoro nie działa, ale z tego co widzę może tam być po prostu zmienna w nawiasach, więc nie powinno być problemu. Standardowy print zarówno ze znakami nowej linii, jak i bez nie działa. Nie sądzę, że tutaj też jest nadal jakiś błąd. Wydaje mi się, że dane są wciąż źle podawane.
>
> Jak podaje dane program:
>
> #include <cstdio>
> #include <cstdint>
>
> #include <random>
>
> int main()
> {
> freopen(NULL, "wb", stdout); // Only necessary on Windows, but harmless.
>
> std::mt19937 rng(42);
>
> while (1) {
> uint32_t value = rng();
> fwrite((void*) &value, sizeof(value), 1, stdout);
> }
> }
>
> https://www.pcg-random.org/posts/how-to-test-with-practrand.html
>
> I czym to się różni od mojego sposobu?
Nie wiem, ale u mnie działa:
cat test.py
import sys
import struct
class SimpPRNG:
x = 0
A = 79908886691
B = 8143076871913
def __init__( self, seed ):
self.x = seed
for i in range(1,100):
self.g()
def g(self):
self.x = (self.x * self.A + self.B) & (2**128-1)
return self.x >> 123
r = SimpPRNG( 1 )
buf = 0
s = 0
while True:
t = r.g()
for i in range(1,5):
buf = buf << 1
buf = buf | (t & 1)
t = t >> 1
s = s + 1
if s == 32:
sys.stdout.write( struct.pack('I', buf) )
s = 0
buf = 0
python test.py | ../c/PractRand/RNG_test stdin
RNG_test using PractRand version 0.94
RNG = RNG_stdin, seed = unknown
test set = core, folding = standard(unknown format)
rng=RNG_stdin, seed=unknown
length= 512 kilobytes (2^19 bytes), time= 2.7 seconds
no anomalies in 84 test result(s)
rng=RNG_stdin, seed=unknown
length= 1 megabyte (2^20 bytes), time= 5.8 seconds
no anomalies in 94 test result(s)
rng=RNG_stdin, seed=unknown
length= 2 megabytes (2^21 bytes), time= 11.5 seconds
no anomalies in 109 test result(s)
rng=RNG_stdin, seed=unknown
length= 4 megabytes (2^22 bytes), time= 22.7 seconds
no anomalies in 124 test result(s)
rng=RNG_stdin, seed=unknown
length= 8 megabytes (2^23 bytes), time= 44.5 seconds
no anomalies in 135 test result(s)
rng=RNG_stdin, seed=unknown
length= 16 megabytes (2^24 bytes), time= 87.8 seconds
no anomalies in 151 test result(s)
^CTraceback (most recent call last):
File "test.py", line 30, in <module>
t = t >> 1
KeyboardInterrupt
Pozdrawim
Technical Details
Message-ID:
<daadfa97-76c3-4ba3-8ee7-801fd5819590n@googlegroups.com>Path:
mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.icm.edu.pl!news.man.lodz.pl!newsfeed.pionier.net.pl!2.eu.feeder.erje.net!feeder.erje.net!news.uzoreto.com!tr2.eu1.usenetexpress.com!feeder.usenetexpress.com!tr3.iad1.usenetexpress.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mailReferences:
<6a2d60cf-5d52-4f70-a0bb-67ac51f2ea47n@googlegroups.com> <0b0e0278-0506-4691-8051-1f73a327e87an@googlegroups.com> <1aabf0e1-8c01-4479-90fc-62d1026d221cn@googlegroups.com> <fcda7316-c8b0-445b-a5d5-2c8db0e2c939n@googlegroups.com> <59524bbe-00b1-4756-b359-19bb000e8641n@googlegroups.com> <2aec1845-1ec1-4e83-835a-ccc9aa089c23n@googlegroups.com> <f201e244-08b1-4ec6-977a-40aba70eac76n@googlegroups.com> <48a87319-4f87-4ace-b9e1-e8c9842514can@googlegroups.com> <5af4b1e3-4d68-4ea8-a5cf-7d2b1075041cn@googlegroups.com> <680b4111-0c0b-4406-ae78-fc27fa1a545an@googlegroups.com> <efe0a67a-6b05-40d2-b877-e5a51f57dd9fn@googlegroups.com> <cb8e26f0-392e-4848-b573-e232e943b6f5n@googlegroups.com> <08cd0111-4022-41af-a03a-a3a4a6307ef6n@googlegroups.com> <c66ce87b-7302-4c87-813b-187c36feffd1n@googlegroups.com> <4a215489-d501-49d5-ade6-cf771ffee901n@googlegroups.com> <7ccd7613-9d6d-4d46-b68f-1db4e9d7a5e3n@googlegroups.com> <9082e2ac-cd7d-436d-80a8-7d12109d3297n@googlegroups.com> <227b1c0e-5d3c-4323-a374-de316aec2ffcn@googlegroups.com> <11f92832-5699-4cf9-be0d-412f9248f4den@googlegroups.com> <97a8c494-64a8-46c0-a17a-114d86aa94d9n@googlegroups.com> <d5976242-a26f-4b4a-93c0-49f7c056c46dn@googlegroups.com> <bf97ae93-0973-4e7d-a7dc-36e681b2479bn@googlegroups.com> <bdc239bf-9878-4a79-a5c4-e007aee2c279n@googlegroups.com> <f453f15f-4c3f-4eee-9714-850a0fb56161n@googlegroups.com> <03af61d9-e808-4daf-82b1-82e45f41372dn@googlegroups.com> <8c2590d8-1517-49f7-b95e-40e5fcaf830bn@googlegroups.com> <f341cef1-76f8-4aa4-ab18-ddf45ba038f3n@googlegroups.com> <a4f24c35-46a4-4dc4-90c0-fa9ee06ce740n@googlegroups.com> <bab05158-796a-4b3f-a52a-42659629ff42n@googlegroups.com> <268d32c4-3f2f-47cd-9544-d15a448f801cn@googlegroups.com> <c9a68c22-8a39-4c63-86e6-cb54d35bfde5n@googlegroups.com> <867ac372-f472-44ea-9346-d99449427a7fn@googlegroups.com> <a1e5bdaf-1701-420b-b2cf-f6831b771a92n@googlegroups.com> <df195a86-c889-47f3-9e9f-e2cb1828efc9n@googlegroups.com> <d2a0fb33-27b9-493e-a88c-fe2e8ec7624bn@googlegroups.com> <21f1661f-f0bc-40af-819b-67e491912f03n@googlegroups.com> <bede20ee-7292-489d-8159-c4460dd09ccdn@googlegroups.com> <1fcfa96a-47ba-4e47-8eea-f9df6a87099bn@googlegroups.com> <715772df-0454-47c9-8dba-ea9f1feb4f77n@googlegroups.com> <18a7e41b-e819-41dc-8749-f4073068d368n@googlegroups.com> <df4a2584-0ce2-4238-9ea2-611b7539a7cdn@googlegroups.com> <9d144f96-4b9c-4b36-b3d3-65f57d60f94cn@googlegroups.com> <585d821d-905b-4480-ae56-23162c4d697fn@googlegroups.com> <412e4c92-95f0-4066-874c-7bcaf7fdc527n@googlegroups.com> <c2aba592-62c0-4c20-b855-3441319f4585n@googlegroups.com> <1b9afe1b-a27d-4769-87af-9731c698bd2an@googlegroups.com> <516761da-c103-438e-89a4-453b5fd105acn@googlegroups.com> <8984b339-4547-45ec-86fd-948cd68fd7f1n@googlegroups.com> <5ef2da7b-8434-4cb9-892c-fbee82a6d058n@googlegroups.com> <aff004e7-7d5a-4bd5-8e4a-3fb8c356f1d4n@googlegroups.com> <6fba279b-cdb5-42b9-9d9e-bc24e7198ecbn@googlegroups.com> <678a6fca-e187-47c4-bdb2-ecbcddac7648n@googlegroups.com> <26012493-7a89-465c-a93e-2ddef0260049n@googlegroups.com> <6943c0be-0407-46e4-b866-379a46765382n@googlegroups.com>Show Full Headers
Complete Article Headers
X-Received: by 2002:ac8:43ca:: with SMTP id w10mr9659439qtn.326.1629798407255; Tue, 24 Aug 2021 02:46:47 -0700 (PDT) X-Received: by 2002:ae9:f50a:: with SMTP id o10mr26472539qkg.387.1629798407115; Tue, 24 Aug 2021 02:46:47 -0700 (PDT) Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.icm.edu.pl!news.man.lodz.pl!newsfeed.pionier.net.pl!2.eu.feeder.erje.net!feeder.erje.net!news.uzoreto.com!tr2.eu1.usenetexpress.com!feeder.usenetexpress.com!tr3.iad1.usenetexpress.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail Newsgroups: pl.comp.programming Date: Tue, 24 Aug 2021 02:46:46 -0700 (PDT) In-Reply-To: <6943c0be-0407-46e4-b866-379a46765382n@googlegroups.com> Injection-Info: google-groups.googlegroups.com; posting-host=37.128.16.171; posting-account=xjvq9QoAAAATMPC2X3btlHd_LkaJo_rj NNTP-Posting-Host: 37.128.16.171 References: <6a2d60cf-5d52-4f70-a0bb-67ac51f2ea47n@googlegroups.com> <0b0e0278-0506-4691-8051-1f73a327e87an@googlegroups.com> <1aabf0e1-8c01-4479-90fc-62d1026d221cn@googlegroups.com> <fcda7316-c8b0-445b-a5d5-2c8db0e2c939n@googlegroups.com> <59524bbe-00b1-4756-b359-19bb000e8641n@googlegroups.com> <2aec1845-1ec1-4e83-835a-ccc9aa089c23n@googlegroups.com> <f201e244-08b1-4ec6-977a-40aba70eac76n@googlegroups.com> <48a87319-4f87-4ace-b9e1-e8c9842514can@googlegroups.com> <5af4b1e3-4d68-4ea8-a5cf-7d2b1075041cn@googlegroups.com> <680b4111-0c0b-4406-ae78-fc27fa1a545an@googlegroups.com> <efe0a67a-6b05-40d2-b877-e5a51f57dd9fn@googlegroups.com> <cb8e26f0-392e-4848-b573-e232e943b6f5n@googlegroups.com> <08cd0111-4022-41af-a03a-a3a4a6307ef6n@googlegroups.com> <c66ce87b-7302-4c87-813b-187c36feffd1n@googlegroups.com> <4a215489-d501-49d5-ade6-cf771ffee901n@googlegroups.com> <7ccd7613-9d6d-4d46-b68f-1db4e9d7a5e3n@googlegroups.com> <9082e2ac-cd7d-436d-80a8-7d12109d3297n@googlegroups.com> <227b1c0e-5d3c-4323-a374-de316aec2ffcn@googlegroups.com> <11f92832-5699-4cf9-be0d-412f9248f4den@googlegroups.com> <97a8c494-64a8-46c0-a17a-114d86aa94d9n@googlegroups.com> <d5976242-a26f-4b4a-93c0-49f7c056c46dn@googlegroups.com> <bf97ae93-0973-4e7d-a7dc-36e681b2479bn@googlegroups.com> <bdc239bf-9878-4a79-a5c4-e007aee2c279n@googlegroups.com> <f453f15f-4c3f-4eee-9714-850a0fb56161n@googlegroups.com> <03af61d9-e808-4daf-82b1-82e45f41372dn@googlegroups.com> <8c2590d8-1517-49f7-b95e-40e5fcaf830bn@googlegroups.com> <f341cef1-76f8-4aa4-ab18-ddf45ba038f3n@googlegroups.com> <a4f24c35-46a4-4dc4-90c0-fa9ee06ce740n@googlegroups.com> <bab05158-796a-4b3f-a52a-42659629ff42n@googlegroups.com> <268d32c4-3f2f-47cd-9544-d15a448f801cn@googlegroups.com> <c9a68c22-8a39-4c63-86e6-cb54d35bfde5n@googlegroups.com> <867ac372-f472-44ea-9346-d99449427a7fn@googlegroups.com> <a1e5bdaf-1701-420b-b2cf-f6831b771a92n@googlegroups.com> <df195a86-c889-47f3-9e9f-e2cb1828efc9n@googlegroups.com> <d2a0fb33-27b9-493e-a88c-fe2e8ec7624bn@googlegroups.com> <21f1661f-f0bc-40af-819b-67e491912f03n@googlegroups.com> <bede20ee-7292-489d-8159-c4460dd09ccdn@googlegroups.com> <1fcfa96a-47ba-4e47-8eea-f9df6a87099bn@googlegroups.com> <715772df-0454-47c9-8dba-ea9f1feb4f77n@googlegroups.com> <18a7e41b-e819-41dc-8749-f4073068d368n@googlegroups.com> <df4a2584-0ce2-4238-9ea2-611b7539a7cdn@googlegroups.com> <9d144f96-4b9c-4b36-b3d3-65f57d60f94cn@googlegroups.com> <585d821d-905b-4480-ae56-23162c4d697fn@googlegroups.com> <412e4c92-95f0-4066-874c-7bcaf7fdc527n@googlegroups.com> <c2aba592-62c0-4c20-b855-3441319f4585n@googlegroups.com> <1b9afe1b-a27d-4769-87af-9731c698bd2an@googlegroups.com> <516761da-c103-438e-89a4-453b5fd105acn@googlegroups.com> <8984b339-4547-45ec-86fd-948cd68fd7f1n@googlegroups.com> <5ef2da7b-8434-4cb9-892c-fbee82a6d058n@googlegroups.com> <aff004e7-7d5a-4bd5-8e4a-3fb8c356f1d4n@googlegroups.com> <6fba279b-cdb5-42b9-9d9e-bc24e7198ecbn@googlegroups.com> <678a6fca-e187-47c4-bdb2-ecbcddac7648n@googlegroups.com> <26012493-7a89-465c-a93e-2ddef0260049n@googlegroups.com> <6943c0be-0407-46e4-b866-379a46765382n@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <daadfa97-76c3-4ba3-8ee7-801fd5819590n@googlegroups.com> Subject: Re: Jak zrobić test za pomocą PractRand? From: "M.M." <mmarszik@gmail.com> Injection-Date: Tue, 24 Aug 2021 09:46:47 +0000 Lines: 120 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit