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


Groups > pl.comp.programming > #34747

Re: Jak zrobić test za pomocą PractRand?

Newsgroups pl.comp.programming
Date 2021-09-22 17:55 -0700
References (64 earlier) <ad0c115d-5404-452f-9821-cf90670bd581n@googlegroups.com> <0d16fb14-2a06-43d2-8f38-55a59b2c2752n@googlegroups.com> <890baef9-9d4a-4be8-953f-fa40bc5d2de7n@googlegroups.com> <10e25059-99a6-4934-a312-38657d8651f6n@googlegroups.com> <b009776e-cdd3-48e0-861a-54d002323d1an@googlegroups.com>
Message-ID <62ec0f80-37a8-42a4-b3e1-b20b1496fe32n@googlegroups.com> (permalink)
Subject Re: Jak zrobić test za pomocą PractRand?
From "osobli...@gmail.com" <osobliwy.nick@gmail.com>

Show all headers | View raw


Bardzo szybki powinien też być ulepszony przeze mnie PCG Melissy O'Neil o nazwie XSL-RR-RR (128-bitowy, choć można stworzyć też wersje 64-bitowe i 32-bitowe):

https://en.wikipedia.org/wiki/Permuted_congruential_generator

Normalnie oblewa on dosyć szybko testy PractRand (kod w Pythonie, sam mixer pewnie można napisać lepiej w C, może jako jakieś macro):

import struct
import sys

x = 83866140117348733064738400095399246193
#seed

def PCGmixer(x):
    count1 = x >> 122
    x1 = (x ^ (x >> 64)) & 18446744073709551615
    low64 = (x1 >> count1) | (x1 << (64 - count1)) & 18446744073709551615
    x2 = (x >> 64) & 18446744073709551615
    count2 = low64 & 63
    high64 = (x2 >> count2) | (x2 << (64 - count2)) & 18446744073709551615
    x = (high64 << 64) | low64
    return x

def LCG(x):
    x = (x * 47026247687942121848144207491837523525 + 83866140218348733064834828227924511723) & 340282366920938463463374607431768211455
    return x

while 1 == 1:

    x=LCG(x)
    w=PCGmixer(x)

    split = [(w >> x) & 0xFFFFFFFF for x in reversed(range(0, 128, 32))]
    binary = struct.pack('IIII', split[0], split[1], split[2], split[3])
    sys.stdout.buffer.write(binary)

Ale wystarczy dodać xorowanie kolejnych wyników:

import struct
import sys

x = 83866140117348733064738400095399246193

def PCGmixer(x):
    count1 = x >> 122
    x1 = (x ^ (x >> 64)) & 18446744073709551615
    low64 = (x1 >> count1) | (x1 << (64 - count1)) & 18446744073709551615
    x2 = (x >> 64) & 18446744073709551615
    count2 = low64 & 63
    high64 = (x2 >> count2) | (x2 << (64 - count2)) & 18446744073709551615
    x = (high64 << 64) | low64
    return x

def LCG(x):
    x = (x * 47026247687942121848144207491837523525 + 83866140218348733064834828227924511723) & 340282366920938463463374607431768211455
    return x

w=0

while 1 == 1:

    w_1 = w

    x=LCG(x)
    w=PCGmixer(x)

    w_2 = w_1 ^ w

    #split = [(w_2 >> x) & 0xFFFFFFFF for x in reversed(range(0, 128, 32))]
    #binary = struct.pack('IIII', split[0], split[1], split[2], split[3])
    #sys.stdout.buffer.write(binary)

Żeby zdawał on testy. Oczywiście sam PCGmixer wydłuża czas pracy istotnie (względem bazowego LCG), ale pewnie można go wykonywać szybciej.

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