Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > pl.comp.programming > #34586

Re: Jak zrobić test za pomocą PractRand?

Newsgroups pl.comp.programming
Date 2021-08-24 07:20 -0700
References (50 earlier) <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> <daadfa97-76c3-4ba3-8ee7-801fd5819590n@googlegroups.com>
Message-ID <f6d66139-d2d8-4712-aeb8-074daa0ebf71n@googlegroups.com> (permalink)
Subject Re: Jak zrobić test za pomocą PractRand?
From "osobli...@gmail.com" <osobliwy.nick@gmail.com>

Show all headers | View raw


wtorek, 24 sierpnia 2021 o 11:46:47 UTC+2 M.M. napisał(a):
> 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

U mnie sys.stdout.write(struct.pack('I', buf)) od razu podświetla się jako błąd. Po uruchomieniu:

TypeError: write() argument must be str, not bytes

Gdy zrobię z argumentu stringa sys.stdout.write(str(struct.pack('I', buf))), to oczywiście oblewa. Trzeba tam jeszcze coś prawdopodobnie dodać, żeby to write działało w trybie binarnym.

Back to pl.comp.programming | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Jak zrobić test za pomocą PractRand? "osobli...@gmail.com" <osobliwy.nick@gmail.com> - 2021-08-19 09:15 -0700
  Re: Jak zrobić test za pomocą PractRand? "osobli...@gmail.com" <osobliwy.nick@gmail.com> - 2021-08-19 15:38 -0700
    Re: Jak zrobić test za pomocą PractRand? "osobli...@gmail.com" <osobliwy.nick@gmail.com> - 2021-08-19 19:16 -0700
  Re: Jak zrobić test za pomocą PractRand? "M.M." <mmarszik@gmail.com> - 2021-08-20 06:04 -0700
    Re: Jak zrobić test za pomocą PractRand? "osobli...@gmail.com" <osobliwy.nick@gmail.com> - 2021-08-20 07:53 -0700
      Re: Jak zrobić test za pomocą PractRand? "M.M." <mmarszik@gmail.com> - 2021-08-20 08:09 -0700
        Re: Jak zrobić test za pomocą PractRand? "osobli...@gmail.com" <osobliwy.nick@gmail.com> - 2021-08-20 09:14 -0700
          Re: Jak zrobić test za pomocą PractRand? "osobli...@gmail.com" <osobliwy.nick@gmail.com> - 2021-08-20 09:57 -0700
          Re: Jak zrobić test za pomocą PractRand? "M.M." <mmarszik@gmail.com> - 2021-08-20 10:26 -0700
            Re: Jak zrobić test za pomocą PractRand? "osobli...@gmail.com" <osobliwy.nick@gmail.com> - 2021-08-20 11:45 -0700
              Re: Jak zrobić test za pomocą PractRand? "M.M." <mmarszik@gmail.com> - 2021-08-20 13:32 -0700
                Re: Jak zrobić test za pomocą PractRand? "osobli...@gmail.com" <osobliwy.nick@gmail.com> - 2021-08-20 14:56 -0700
                Re: Jak zrobić test za pomocą PractRand? "M.M." <mmarszik@gmail.com> - 2021-08-20 15:11 -0700
                Re: Jak zrobić test za pomocą PractRand? "osobli...@gmail.com" <osobliwy.nick@gmail.com> - 2021-08-20 15:20 -0700
                Re: Jak zrobić test za pomocą PractRand? "osobli...@gmail.com" <osobliwy.nick@gmail.com> - 2021-08-20 15:27 -0700
                Re: Jak zrobić test za pomocą PractRand? "M.M." <mmarszik@gmail.com> - 2021-08-20 15:49 -0700
                Re: Jak zrobić test za pomocą PractRand? "osobli...@gmail.com" <osobliwy.nick@gmail.com> - 2021-08-20 16:55 -0700
                Re: Jak zrobić test za pomocą PractRand? "M.M." <mmarszik@gmail.com> - 2021-08-21 02:40 -0700
                Re: Jak zrobić test za pomocą PractRand? "M.M." <mmarszik@gmail.com> - 2021-08-21 04:27 -0700
                Re: Jak zrobić test za pomocą PractRand? "osobli...@gmail.com" <osobliwy.nick@gmail.com> - 2021-08-21 08:51 -0700
                Re: Jak zrobić test za pomocą PractRand? "M.M." <mmarszik@gmail.com> - 2021-08-21 09:30 -0700
                Re: Jak zrobić test za pomocą PractRand? "osobli...@gmail.com" <osobliwy.nick@gmail.com> - 2021-08-21 10:16 -0700
                Re: Jak zrobić test za pomocą PractRand? "osobli...@gmail.com" <osobliwy.nick@gmail.com> - 2021-08-21 12:24 -0700
                Re: Jak zrobić test za pomocą PractRand? "M.M." <mmarszik@gmail.com> - 2021-08-21 12:48 -0700
                Re: Jak zrobić test za pomocą PractRand? "M.M." <mmarszik@gmail.com> - 2021-08-21 12:57 -0700
                Re: Jak zrobić test za pomocą PractRand? "osobli...@gmail.com" <osobliwy.nick@gmail.com> - 2021-08-21 13:55 -0700
                Re: Jak zrobić test za pomocą PractRand? "osobli...@gmail.com" <osobliwy.nick@gmail.com> - 2021-08-21 13:58 -0700
                Re: Jak zrobić test za pomocą PractRand? "M.M." <mmarszik@gmail.com> - 2021-08-21 14:22 -0700
                Re: Jak zrobić test za pomocą PractRand? "osobli...@gmail.com" <osobliwy.nick@gmail.com> - 2021-08-21 14:35 -0700
                Re: Jak zrobić test za pomocą PractRand? "osobli...@gmail.com" <osobliwy.nick@gmail.com> - 2021-08-21 14:37 -0700
                Re: Jak zrobić test za pomocą PractRand? "osobli...@gmail.com" <osobliwy.nick@gmail.com> - 2021-08-21 14:42 -0700
                Re: Jak zrobić test za pomocą PractRand? "osobli...@gmail.com" <osobliwy.nick@gmail.com> - 2021-08-21 15:17 -0700
                Re: Jak zrobić test za pomocą PractRand? "M.M." <mmarszik@gmail.com> - 2021-08-21 17:31 -0700
                Re: Jak zrobić test za pomocą PractRand? "osobli...@gmail.com" <osobliwy.nick@gmail.com> - 2021-08-21 17:37 -0700
                Re: Jak zrobić test za pomocą PractRand? "M.M." <mmarszik@gmail.com> - 2021-08-21 17:44 -0700
                Re: Jak zrobić test za pomocą PractRand? "osobli...@gmail.com" <osobliwy.nick@gmail.com> - 2021-08-21 17:32 -0700
                Re: Jak zrobić test za pomocą PractRand? "M.M." <mmarszik@gmail.com> - 2021-08-21 17:43 -0700
                Re: Jak zrobić test za pomocą PractRand? "osobli...@gmail.com" <osobliwy.nick@gmail.com> - 2021-08-21 17:47 -0700
                Re: Jak zrobić test za pomocą PractRand? "M.M." <mmarszik@gmail.com> - 2021-08-21 17:54 -0700
                Re: Jak zrobić test za pomocą PractRand? "osobli...@gmail.com" <osobliwy.nick@gmail.com> - 2021-08-21 17:58 -0700
                Re: Jak zrobić test za pomocą PractRand? "osobli...@gmail.com" <osobliwy.nick@gmail.com> - 2021-08-21 18:10 -0700
                Re: Jak zrobić test za pomocą PractRand? "osobli...@gmail.com" <osobliwy.nick@gmail.com> - 2021-08-21 20:08 -0700
                Re: Jak zrobić test za pomocą PractRand? "M.M." <mmarszik@gmail.com> - 2021-08-22 01:39 -0700
                Re: Jak zrobić test za pomocą PractRand? "osobli...@gmail.com" <osobliwy.nick@gmail.com> - 2021-08-22 05:01 -0700
                Re: Jak zrobić test za pomocą PractRand? "osobli...@gmail.com" <osobliwy.nick@gmail.com> - 2021-08-22 06:08 -0700
                Re: Jak zrobić test za pomocą PractRand? "M.M." <mmarszik@gmail.com> - 2021-08-22 09:41 -0700
                Re: Jak zrobić test za pomocą PractRand? "osobli...@gmail.com" <osobliwy.nick@gmail.com> - 2021-08-22 11:59 -0700
                Re: Jak zrobić test za pomocą PractRand? "M.M." <mmarszik@gmail.com> - 2021-08-22 13:06 -0700
                Re: Jak zrobić test za pomocą PractRand? "osobli...@gmail.com" <osobliwy.nick@gmail.com> - 2021-08-22 13:17 -0700
                Re: Jak zrobić test za pomocą PractRand? "M.M." <mmarszik@gmail.com> - 2021-08-22 13:58 -0700
                Re: Jak zrobić test za pomocą PractRand? "osobli...@gmail.com" <osobliwy.nick@gmail.com> - 2021-08-22 14:28 -0700
                Re: Jak zrobić test za pomocą PractRand? "osobli...@gmail.com" <osobliwy.nick@gmail.com> - 2021-08-22 15:29 -0700
                Re: Jak zrobić test za pomocą PractRand? "M.M." <mmarszik@gmail.com> - 2021-08-22 16:06 -0700
                Re: Jak zrobić test za pomocą PractRand? "M.M." <mmarszik@gmail.com> - 2021-08-22 15:58 -0700
                Re: Jak zrobić test za pomocą PractRand? "osobli...@gmail.com" <osobliwy.nick@gmail.com> - 2021-08-22 17:08 -0700
                Re: Jak zrobić test za pomocą PractRand? "osobli...@gmail.com" <osobliwy.nick@gmail.com> - 2021-08-22 20:23 -0700
                Re: Jak zrobić test za pomocą PractRand? "M.M." <mmarszik@gmail.com> - 2021-08-23 02:18 -0700
                Re: Jak zrobić test za pomocą PractRand? "osobli...@gmail.com" <osobliwy.nick@gmail.com> - 2021-08-23 05:31 -0700
                Re: Jak zrobić test za pomocą PractRand? "M.M." <mmarszik@gmail.com> - 2021-08-23 06:05 -0700
                Re: Jak zrobić test za pomocą PractRand? "osobli...@gmail.com" <osobliwy.nick@gmail.com> - 2021-08-23 06:21 -0700
                Re: Jak zrobić test za pomocą PractRand? "M.M." <mmarszik@gmail.com> - 2021-08-23 06:58 -0700
                Re: Jak zrobić test za pomocą PractRand? "osobli...@gmail.com" <osobliwy.nick@gmail.com> - 2021-08-23 12:11 -0700
                Re: Jak zrobić test za pomocą PractRand? "M.M." <mmarszik@gmail.com> - 2021-08-23 13:29 -0700
                Re: Jak zrobić test za pomocą PractRand? "osobli...@gmail.com" <osobliwy.nick@gmail.com> - 2021-08-23 13:47 -0700
                Re: Jak zrobić test za pomocą PractRand? "osobli...@gmail.com" <osobliwy.nick@gmail.com> - 2021-08-23 14:06 -0700
                Re: Jak zrobić test za pomocą PractRand? "osobli...@gmail.com" <osobliwy.nick@gmail.com> - 2021-08-23 14:19 -0700
                Re: Jak zrobić test za pomocą PractRand? "M.M." <mmarszik@gmail.com> - 2021-08-23 14:46 -0700
                Re: Jak zrobić test za pomocą PractRand? "osobli...@gmail.com" <osobliwy.nick@gmail.com> - 2021-08-23 15:27 -0700
                Re: Jak zrobić test za pomocą PractRand? "osobli...@gmail.com" <osobliwy.nick@gmail.com> - 2021-08-23 15:54 -0700
                Re: Jak zrobić test za pomocą PractRand? "osobli...@gmail.com" <osobliwy.nick@gmail.com> - 2021-08-23 16:43 -0700
                Re: Jak zrobić test za pomocą PractRand? "M.M." <mmarszik@gmail.com> - 2021-08-24 02:46 -0700
                Re: Jak zrobić test za pomocą PractRand? "osobli...@gmail.com" <osobliwy.nick@gmail.com> - 2021-08-24 07:20 -0700
                Re: Jak zrobić test za pomocą PractRand? "osobli...@gmail.com" <osobliwy.nick@gmail.com> - 2021-08-24 07:26 -0700
                Re: Jak zrobić test za pomocą PractRand? "osobli...@gmail.com" <osobliwy.nick@gmail.com> - 2021-08-24 07:42 -0700
                Re: Jak zrobić test za pomocą PractRand? "osobli...@gmail.com" <osobliwy.nick@gmail.com> - 2021-08-24 08:49 -0700
                Re: Jak zrobić test za pomocą PractRand? "M.M." <mmarszik@gmail.com> - 2021-08-24 09:15 -0700
                Re: Jak zrobić test za pomocą PractRand? "osobli...@gmail.com" <osobliwy.nick@gmail.com> - 2021-08-24 19:15 -0700
                Re: Jak zrobić test za pomocą PractRand? "osobli...@gmail.com" <osobliwy.nick@gmail.com> - 2021-08-24 19:24 -0700
                Re: Jak zrobić test za pomocą PractRand? "osobli...@gmail.com" <osobliwy.nick@gmail.com> - 2021-08-26 14:45 -0700
                Re: Jak zrobić test za pomocą PractRand? "osobli...@gmail.com" <osobliwy.nick@gmail.com> - 2021-08-26 15:52 -0700
                Re: Jak zrobić test za pomocą PractRand? "osobli...@gmail.com" <osobliwy.nick@gmail.com> - 2021-08-29 07:29 -0700
                Re: Jak zrobić test za pomocą PractRand? "M.M." <mmarszik@gmail.com> - 2021-08-30 12:38 -0700
                Re: Jak zrobić test za pomocą PractRand? "osobli...@gmail.com" <osobliwy.nick@gmail.com> - 2021-08-30 15:57 -0700
                Re: Jak zrobić test za pomocą PractRand? "M.M." <mmarszik@gmail.com> - 2021-08-30 17:31 -0700
                Re: Jak zrobić test za pomocą PractRand? "osobli...@gmail.com" <osobliwy.nick@gmail.com> - 2021-09-22 17:28 -0700
                Re: Jak zrobić test za pomocą PractRand? "osobli...@gmail.com" <osobliwy.nick@gmail.com> - 2021-09-22 17:55 -0700
                Re: Jak zrobić test za pomocą PractRand? "M.M." <mmarszik@gmail.com> - 2021-08-30 17:36 -0700
                Re: Jak zrobić test za pomocą PractRand? "osobli...@gmail.com" <osobliwy.nick@gmail.com> - 2021-08-31 01:04 -0700
                Re: Jak zrobić test za pomocą PractRand? "osobli...@gmail.com" <osobliwy.nick@gmail.com> - 2023-06-16 04:32 -0700
                Re: Jak zrobić test za pomocą PractRand? "osobli...@gmail.com" <osobliwy.nick@gmail.com> - 2023-06-16 05:05 -0700
                Re: Jak zrobić test za pomocą PractRand? "osobli...@gmail.com" <osobliwy.nick@gmail.com> - 2023-06-16 05:07 -0700
                Re: Jak zrobić test za pomocą PractRand? "osobli...@gmail.com" <osobliwy.nick@gmail.com> - 2023-06-16 05:11 -0700
                Re: Jak zrobić test za pomocą PractRand? "osobli...@gmail.com" <osobliwy.nick@gmail.com> - 2023-06-20 20:48 -0700
                Re: Jak zrobić test za pomocą PractRand? "M.M." <mmarszik@gmail.com> - 2021-08-24 09:05 -0700
                Re: Jak zrobić test za pomocą PractRand? "M.M." <mmarszik@gmail.com> - 2021-08-21 17:33 -0700
                Re: Jak zrobić test za pomocą PractRand? "M.M." <mmarszik@gmail.com> - 2021-08-21 17:46 -0700
                Re: Jak zrobić test za pomocą PractRand? "osobli...@gmail.com" <osobliwy.nick@gmail.com> - 2021-08-21 17:56 -0700
                Re: Jak zrobić test za pomocą PractRand? "M.M." <mmarszik@gmail.com> - 2021-08-21 14:31 -0700
                Re: Jak zrobić test za pomocą PractRand? "osobli...@gmail.com" <osobliwy.nick@gmail.com> - 2021-08-21 07:53 -0700
                Re: Jak zrobić test za pomocą PractRand? "M.M." <mmarszik@gmail.com> - 2021-08-21 08:18 -0700

csiph-web