mirror of
https://github.com/golang/go
synced 2024-11-11 19:21:37 -07:00
math/rand/v2: delete Mitchell/Reeds source
These slowdowns are because we are now using PCG instead of the Mitchell/Reeds LFSR for the benchmarks. PCG is in fact a bit slower (but generates statically far better random numbers). goos: linux goarch: amd64 pkg: math/rand/v2 cpu: AMD Ryzen 9 7950X 16-Core Processor │ 01ff938549.amd64 │ afa459a2f0.amd64 │ │ sec/op │ sec/op vs base │ PCG_DXSM-32 1.490n ± 0% 1.488n ± 2% ~ (p=0.408 n=20) SourceUint64-32 1.352n ± 1% 1.450n ± 3% +7.21% (p=0.000 n=20) GlobalInt64-32 2.083n ± 0% 2.067n ± 2% ~ (p=0.223 n=20) GlobalInt64Parallel-32 0.1035n ± 1% 0.1044n ± 2% ~ (p=0.010 n=20) GlobalUint64-32 2.038n ± 1% 2.085n ± 0% +2.28% (p=0.000 n=20) GlobalUint64Parallel-32 0.1006n ± 1% 0.1008n ± 1% ~ (p=0.733 n=20) Int64-32 1.687n ± 2% 1.779n ± 1% +5.48% (p=0.000 n=20) Uint64-32 1.674n ± 2% 1.854n ± 2% +10.69% (p=0.000 n=20) GlobalIntN1000-32 3.135n ± 1% 3.140n ± 3% ~ (p=0.794 n=20) IntN1000-32 2.478n ± 1% 2.496n ± 1% +0.73% (p=0.006 n=20) Int64N1000-32 2.455n ± 1% 2.510n ± 2% +2.22% (p=0.000 n=20) Int64N1e8-32 2.467n ± 2% 2.471n ± 2% ~ (p=0.050 n=20) Int64N1e9-32 2.454n ± 1% 2.488n ± 2% +1.39% (p=0.000 n=20) Int64N2e9-32 2.482n ± 1% 2.478n ± 2% ~ (p=0.066 n=20) Int64N1e18-32 3.349n ± 2% 3.088n ± 1% -7.81% (p=0.000 n=20) Int64N2e18-32 3.537n ± 1% 3.493n ± 1% -1.24% (p=0.002 n=20) Int64N4e18-32 4.917n ± 0% 5.060n ± 2% +2.91% (p=0.000 n=20) Int32N1000-32 2.386n ± 1% 2.620n ± 1% +9.76% (p=0.000 n=20) Int32N1e8-32 2.366n ± 1% 2.652n ± 0% +12.11% (p=0.000 n=20) Int32N1e9-32 2.355n ± 2% 2.644n ± 1% +12.32% (p=0.000 n=20) Int32N2e9-32 2.371n ± 1% 2.619n ± 2% +10.48% (p=0.000 n=20) Float32-32 2.245n ± 2% 2.261n ± 1% ~ (p=0.625 n=20) Float64-32 2.235n ± 1% 2.241n ± 2% ~ (p=0.393 n=20) ExpFloat64-32 3.813n ± 3% 3.716n ± 1% -2.53% (p=0.000 n=20) NormFloat64-32 3.652n ± 2% 3.718n ± 1% +1.79% (p=0.006 n=20) Perm3-32 33.12n ± 3% 34.11n ± 2% ~ (p=0.021 n=20) Perm30-32 205.1n ± 1% 200.6n ± 0% -2.17% (p=0.000 n=20) Perm30ViaShuffle-32 110.8n ± 1% 109.7n ± 1% -0.99% (p=0.002 n=20) ShuffleOverhead-32 113.0n ± 1% 107.2n ± 1% -5.09% (p=0.000 n=20) Concurrent-32 2.100n ± 0% 2.108n ± 6% ~ (p=0.103 n=20) goos: darwin goarch: arm64 pkg: math/rand/v2 │ 01ff938549.arm64 │ afa459a2f0.arm64 │ │ sec/op │ sec/op vs base │ PCG_DXSM-8 2.531n ± 0% 2.531n ± 0% ~ (p=0.763 n=20) SourceUint64-8 2.258n ± 1% 2.531n ± 0% +12.09% (p=0.000 n=20) GlobalInt64-8 2.167n ± 0% 2.177n ± 1% ~ (p=0.213 n=20) GlobalInt64Parallel-8 0.4310n ± 0% 0.4319n ± 0% ~ (p=0.027 n=20) GlobalUint64-8 2.182n ± 1% 2.185n ± 1% ~ (p=0.683 n=20) GlobalUint64Parallel-8 0.4297n ± 0% 0.4295n ± 1% ~ (p=0.941 n=20) Int64-8 2.472n ± 1% 4.104n ± 0% +66.00% (p=0.000 n=20) Uint64-8 2.449n ± 1% 4.080n ± 0% +66.60% (p=0.000 n=20) GlobalIntN1000-8 2.814n ± 2% 2.814n ± 1% ~ (p=0.972 n=20) IntN1000-8 2.998n ± 2% 4.140n ± 0% +38.09% (p=0.000 n=20) Int64N1000-8 2.949n ± 2% 4.139n ± 0% +40.35% (p=0.000 n=20) Int64N1e8-8 2.953n ± 2% 4.140n ± 0% +40.22% (p=0.000 n=20) Int64N1e9-8 2.950n ± 0% 4.139n ± 0% +40.32% (p=0.000 n=20) Int64N2e9-8 2.946n ± 2% 4.140n ± 0% +40.53% (p=0.000 n=20) Int64N1e18-8 3.779n ± 1% 5.273n ± 0% +39.52% (p=0.000 n=20) Int64N2e18-8 4.370n ± 1% 6.059n ± 0% +38.65% (p=0.000 n=20) Int64N4e18-8 6.544n ± 1% 8.803n ± 0% +34.52% (p=0.000 n=20) Int32N1000-8 2.950n ± 0% 4.131n ± 0% +40.06% (p=0.000 n=20) Int32N1e8-8 2.950n ± 2% 4.131n ± 0% +40.03% (p=0.000 n=20) Int32N1e9-8 2.951n ± 2% 4.131n ± 0% +39.99% (p=0.000 n=20) Int32N2e9-8 2.950n ± 2% 4.131n ± 0% +40.03% (p=0.000 n=20) Float32-8 3.441n ± 0% 4.110n ± 0% +19.44% (p=0.000 n=20) Float64-8 3.442n ± 0% 4.104n ± 0% +19.24% (p=0.000 n=20) ExpFloat64-8 4.481n ± 0% 5.338n ± 0% +19.11% (p=0.000 n=20) NormFloat64-8 4.725n ± 0% 5.731n ± 0% +21.28% (p=0.000 n=20) Perm3-8 26.55n ± 0% 26.62n ± 0% +0.28% (p=0.000 n=20) Perm30-8 181.9n ± 0% 194.6n ± 2% +6.98% (p=0.000 n=20) Perm30ViaShuffle-8 142.9n ± 0% 156.4n ± 0% +9.45% (p=0.000 n=20) ShuffleOverhead-8 120.8n ± 2% 125.8n ± 0% +4.10% (p=0.000 n=20) Concurrent-8 2.421n ± 6% 2.654n ± 6% +9.67% (p=0.002 n=20) goos: linux goarch: 386 pkg: math/rand/v2 cpu: AMD Ryzen 9 7950X 16-Core Processor │ 01ff938549.386 │ afa459a2f0.386 │ │ sec/op │ sec/op vs base │ PCG_DXSM-32 7.613n ± 1% 7.793n ± 2% +2.38% (p=0.000 n=20) SourceUint64-32 2.069n ± 0% 7.680n ± 1% +271.19% (p=0.000 n=20) GlobalInt64-32 3.456n ± 1% 3.474n ± 3% ~ (p=0.654 n=20) GlobalInt64Parallel-32 0.3252n ± 0% 0.3253n ± 0% ~ (p=0.952 n=20) GlobalUint64-32 3.573n ± 1% 3.433n ± 2% -3.92% (p=0.000 n=20) GlobalUint64Parallel-32 0.3159n ± 0% 0.3156n ± 0% ~ (p=0.223 n=20) Int64-32 2.562n ± 2% 7.707n ± 1% +200.74% (p=0.000 n=20) Uint64-32 2.592n ± 0% 7.714n ± 1% +197.65% (p=0.000 n=20) GlobalIntN1000-32 6.266n ± 2% 6.236n ± 1% ~ (p=0.039 n=20) IntN1000-32 4.724n ± 2% 10.410n ± 1% +120.39% (p=0.000 n=20) Int64N1000-32 5.490n ± 2% 10.975n ± 2% +99.89% (p=0.000 n=20) Int64N1e8-32 5.513n ± 2% 10.980n ± 1% +99.15% (p=0.000 n=20) Int64N1e9-32 5.476n ± 1% 10.950n ± 0% +99.96% (p=0.000 n=20) Int64N2e9-32 5.501n ± 2% 11.110n ± 1% +101.96% (p=0.000 n=20) Int64N1e18-32 9.043n ± 2% 15.180n ± 2% +67.86% (p=0.000 n=20) Int64N2e18-32 9.601n ± 2% 15.610n ± 1% +62.60% (p=0.000 n=20) Int64N4e18-32 12.00n ± 1% 19.23n ± 2% +60.14% (p=0.000 n=20) Int32N1000-32 4.829n ± 2% 10.345n ± 1% +114.25% (p=0.000 n=20) Int32N1e8-32 4.825n ± 2% 10.330n ± 1% +114.09% (p=0.000 n=20) Int32N1e9-32 4.830n ± 2% 10.350n ± 1% +114.26% (p=0.000 n=20) Int32N2e9-32 4.750n ± 2% 10.345n ± 1% +117.81% (p=0.000 n=20) Float32-32 10.89n ± 4% 13.57n ± 1% +24.61% (p=0.000 n=20) Float64-32 19.60n ± 4% 22.95n ± 4% +17.12% (p=0.000 n=20) ExpFloat64-32 12.96n ± 3% 15.23n ± 2% +17.47% (p=0.000 n=20) NormFloat64-32 7.516n ± 1% 13.780n ± 1% +83.34% (p=0.000 n=20) Perm3-32 36.78n ± 2% 46.62n ± 2% +26.72% (p=0.000 n=20) Perm30-32 238.9n ± 2% 400.7n ± 1% +67.73% (p=0.000 n=20) Perm30ViaShuffle-32 189.7n ± 2% 350.5n ± 1% +84.79% (p=0.000 n=20) ShuffleOverhead-32 159.8n ± 1% 326.0n ± 2% +104.01% (p=0.000 n=20) Concurrent-32 3.286n ± 1% 3.290n ± 0% ~ (p=0.743 n=20) On the other hand, compared to the original "update benchmarks" CL, the cleanups we've made more than compensate for PCG being a bit slower than LFSR, at least on 64-bit x86. ARM64 (Apple M1) is a bit slower: perhaps the 64x64→128 multiply is slower there for some reason. 386 is noticeably slower, but it's also a non-SSA backend. goos: linux goarch: amd64 pkg: math/rand/v2 cpu: AMD Ryzen 9 7950X 16-Core Processor │ 220860f76f.amd64 │ afa459a2f0.amd64 │ │ sec/op │ sec/op vs base │ SourceUint64-32 1.555n ± 1% 1.450n ± 3% -6.78% (p=0.000 n=20) GlobalInt64-32 2.071n ± 1% 2.067n ± 2% ~ (p=0.673 n=20) GlobalInt63Parallel-32 0.1023n ± 1% GlobalInt64Parallel-32 0.1044n ± 2% GlobalUint64-32 5.193n ± 1% 2.085n ± 0% -59.86% (p=0.000 n=20) GlobalUint64Parallel-32 0.2341n ± 0% 0.1008n ± 1% -56.93% (p=0.000 n=20) Int64-32 2.056n ± 2% 1.779n ± 1% -13.47% (p=0.000 n=20) Uint64-32 2.077n ± 2% 1.854n ± 2% -10.74% (p=0.000 n=20) GlobalIntN1000-32 4.077n ± 2% 3.140n ± 3% -22.98% (p=0.000 n=20) IntN1000-32 3.476n ± 2% 2.496n ± 1% -28.19% (p=0.000 n=20) Int64N1000-32 3.059n ± 1% 2.510n ± 2% -17.96% (p=0.000 n=20) Int64N1e8-32 2.942n ± 1% 2.471n ± 2% -15.98% (p=0.000 n=20) Int64N1e9-32 2.932n ± 1% 2.488n ± 2% -15.14% (p=0.000 n=20) Int64N2e9-32 2.925n ± 1% 2.478n ± 2% -15.30% (p=0.000 n=20) Int64N1e18-32 3.116n ± 1% 3.088n ± 1% ~ (p=0.013 n=20) Int64N2e18-32 4.067n ± 1% 3.493n ± 1% -14.11% (p=0.000 n=20) Int64N4e18-32 4.054n ± 1% 5.060n ± 2% +24.80% (p=0.000 n=20) Int32N1000-32 2.951n ± 1% 2.620n ± 1% -11.22% (p=0.000 n=20) Int32N1e8-32 3.102n ± 1% 2.652n ± 0% -14.50% (p=0.000 n=20) Int32N1e9-32 3.535n ± 1% 2.644n ± 1% -25.20% (p=0.000 n=20) Int32N2e9-32 3.514n ± 1% 2.619n ± 2% -25.47% (p=0.000 n=20) Float32-32 2.760n ± 1% 2.261n ± 1% -18.06% (p=0.000 n=20) Float64-32 2.284n ± 1% 2.241n ± 2% ~ (p=0.016 n=20) ExpFloat64-32 3.757n ± 1% 3.716n ± 1% ~ (p=0.034 n=20) NormFloat64-32 3.837n ± 1% 3.718n ± 1% -3.09% (p=0.000 n=20) Perm3-32 35.23n ± 2% 34.11n ± 2% -3.19% (p=0.000 n=20) Perm30-32 208.8n ± 1% 200.6n ± 0% -3.93% (p=0.000 n=20) Perm30ViaShuffle-32 111.7n ± 1% 109.7n ± 1% -1.84% (p=0.000 n=20) ShuffleOverhead-32 101.1n ± 1% 107.2n ± 1% +6.03% (p=0.000 n=20) Concurrent-32 2.108n ± 7% 2.108n ± 6% ~ (p=0.644 n=20) PCG_DXSM-32 1.488n ± 2% goos: darwin goarch: arm64 pkg: math/rand/v2 cpu: Apple M1 │ 220860f76f.arm64 │ afa459a2f0.arm64 │ │ sec/op │ sec/op vs base │ SourceUint64-8 2.316n ± 1% 2.531n ± 0% +9.33% (p=0.000 n=20) GlobalInt64-8 2.183n ± 1% 2.177n ± 1% ~ (p=0.533 n=20) GlobalInt63Parallel-8 0.4331n ± 0% GlobalInt64Parallel-8 0.4319n ± 0% GlobalUint64-8 4.377n ± 2% 2.185n ± 1% -50.07% (p=0.000 n=20) GlobalUint64Parallel-8 0.9237n ± 0% 0.4295n ± 1% -53.50% (p=0.000 n=20) Int64-8 2.538n ± 1% 4.104n ± 0% +61.68% (p=0.000 n=20) Uint64-8 2.604n ± 1% 4.080n ± 0% +56.68% (p=0.000 n=20) GlobalIntN1000-8 3.857n ± 2% 2.814n ± 1% -27.04% (p=0.000 n=20) IntN1000-8 3.822n ± 2% 4.140n ± 0% +8.32% (p=0.000 n=20) Int64N1000-8 3.318n ± 0% 4.139n ± 0% +24.74% (p=0.000 n=20) Int64N1e8-8 3.349n ± 1% 4.140n ± 0% +23.64% (p=0.000 n=20) Int64N1e9-8 3.317n ± 2% 4.139n ± 0% +24.80% (p=0.000 n=20) Int64N2e9-8 3.317n ± 2% 4.140n ± 0% +24.81% (p=0.000 n=20) Int64N1e18-8 3.542n ± 1% 5.273n ± 0% +48.85% (p=0.000 n=20) Int64N2e18-8 5.087n ± 0% 6.059n ± 0% +19.12% (p=0.000 n=20) Int64N4e18-8 5.084n ± 0% 8.803n ± 0% +73.16% (p=0.000 n=20) Int32N1000-8 3.208n ± 2% 4.131n ± 0% +28.79% (p=0.000 n=20) Int32N1e8-8 3.610n ± 1% 4.131n ± 0% +14.43% (p=0.000 n=20) Int32N1e9-8 4.235n ± 0% 4.131n ± 0% -2.44% (p=0.000 n=20) Int32N2e9-8 4.229n ± 1% 4.131n ± 0% -2.33% (p=0.000 n=20) Float32-8 3.468n ± 0% 4.110n ± 0% +18.50% (p=0.000 n=20) Float64-8 3.447n ± 0% 4.104n ± 0% +19.05% (p=0.000 n=20) ExpFloat64-8 4.567n ± 0% 5.338n ± 0% +16.86% (p=0.000 n=20) NormFloat64-8 4.821n ± 0% 5.731n ± 0% +18.89% (p=0.000 n=20) Perm3-8 28.89n ± 0% 26.62n ± 0% -7.84% (p=0.000 n=20) Perm30-8 175.7n ± 0% 194.6n ± 2% +10.76% (p=0.000 n=20) Perm30ViaShuffle-8 153.5n ± 0% 156.4n ± 0% +1.86% (p=0.000 n=20) ShuffleOverhead-8 119.8n ± 1% 125.8n ± 0% +4.97% (p=0.000 n=20) Concurrent-8 2.433n ± 3% 2.654n ± 6% +9.13% (p=0.001 n=20) PCG_DXSM-8 2.531n ± 0% goos: linux goarch: 386 pkg: math/rand/v2 cpu: AMD Ryzen 9 7950X 16-Core Processor │ 220860f76f.386 │ afa459a2f0.386 │ │ sec/op │ sec/op vs base │ SourceUint64-32 2.370n ± 1% 7.680n ± 1% +224.05% (p=0.000 n=20) GlobalInt64-32 3.569n ± 1% 3.474n ± 3% -2.66% (p=0.001 n=20) GlobalInt63Parallel-32 0.3221n ± 1% GlobalInt64Parallel-32 0.3253n ± 0% GlobalUint64-32 8.797n ± 10% 3.433n ± 2% -60.98% (p=0.000 n=20) GlobalUint64Parallel-32 0.6351n ± 0% 0.3156n ± 0% -50.31% (p=0.000 n=20) Int64-32 2.612n ± 2% 7.707n ± 1% +195.04% (p=0.000 n=20) Uint64-32 3.350n ± 1% 7.714n ± 1% +130.25% (p=0.000 n=20) GlobalIntN1000-32 5.892n ± 1% 6.236n ± 1% +5.82% (p=0.000 n=20) IntN1000-32 4.546n ± 1% 10.410n ± 1% +128.97% (p=0.000 n=20) Int64N1000-32 14.59n ± 1% 10.97n ± 2% -24.75% (p=0.000 n=20) Int64N1e8-32 14.76n ± 2% 10.98n ± 1% -25.58% (p=0.000 n=20) Int64N1e9-32 16.57n ± 1% 10.95n ± 0% -33.90% (p=0.000 n=20) Int64N2e9-32 14.54n ± 1% 11.11n ± 1% -23.62% (p=0.000 n=20) Int64N1e18-32 16.14n ± 1% 15.18n ± 2% -5.95% (p=0.000 n=20) Int64N2e18-32 18.10n ± 1% 15.61n ± 1% -13.73% (p=0.000 n=20) Int64N4e18-32 18.65n ± 1% 19.23n ± 2% +3.08% (p=0.000 n=20) Int32N1000-32 3.560n ± 1% 10.345n ± 1% +190.55% (p=0.000 n=20) Int32N1e8-32 3.770n ± 2% 10.330n ± 1% +174.01% (p=0.000 n=20) Int32N1e9-32 4.098n ± 0% 10.350n ± 1% +152.53% (p=0.000 n=20) Int32N2e9-32 4.179n ± 1% 10.345n ± 1% +147.52% (p=0.000 n=20) Float32-32 21.18n ± 4% 13.57n ± 1% -35.93% (p=0.000 n=20) Float64-32 20.60n ± 2% 22.95n ± 4% +11.41% (p=0.000 n=20) ExpFloat64-32 13.07n ± 0% 15.23n ± 2% +16.48% (p=0.000 n=20) NormFloat64-32 7.738n ± 2% 13.780n ± 1% +78.08% (p=0.000 n=20) Perm3-32 36.73n ± 1% 46.62n ± 2% +26.91% (p=0.000 n=20) Perm30-32 211.9n ± 1% 400.7n ± 1% +89.05% (p=0.000 n=20) Perm30ViaShuffle-32 165.2n ± 1% 350.5n ± 1% +112.20% (p=0.000 n=20) ShuffleOverhead-32 133.9n ± 1% 326.0n ± 2% +143.37% (p=0.000 n=20) Concurrent-32 3.287n ± 2% 3.290n ± 0% ~ (p=0.365 n=20) PCG_DXSM-32 7.793n ± 2% For #61716. Change-Id: I4e9c0525b5f84a2ac46f23da9e365495e2d05777 Reviewed-on: https://go-review.googlesource.com/c/go/+/502506 Reviewed-by: Rob Pike <r@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Auto-Submit: Russ Cox <rsc@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
This commit is contained in:
parent
8631fcbf31
commit
8abde68f19
@ -10,7 +10,6 @@ pkg math/rand/v2, func IntN(int) int #61716
|
||||
pkg math/rand/v2, func N[$0 intType]($0) $0 #61716
|
||||
pkg math/rand/v2, func New(Source) *Rand #61716
|
||||
pkg math/rand/v2, func NewPCG(uint64, uint64) *PCG #61716
|
||||
pkg math/rand/v2, func NewSource(int64) Source #61716
|
||||
pkg math/rand/v2, func NewZipf(*Rand, float64, float64, uint64) *Zipf #61716
|
||||
pkg math/rand/v2, func NormFloat64() float64 #61716
|
||||
pkg math/rand/v2, func Perm(int) []int #61716
|
||||
|
@ -26,7 +26,7 @@ func TestAuto(t *testing.T) {
|
||||
// Strictly speaking, we should look for them in order,
|
||||
// but this is good enough and not significantly more
|
||||
// likely to have a false positive.
|
||||
r := New(NewSource(1))
|
||||
r := New(NewPCG(1, 0))
|
||||
found := 0
|
||||
for i := 0; i < 1000; i++ {
|
||||
x := r.Int64()
|
||||
|
@ -46,9 +46,9 @@ func Example() {
|
||||
// The use of the global functions is the same, without the receiver.
|
||||
func Example_rand() {
|
||||
// Create and seed the generator.
|
||||
// Typically a non-fixed seed should be used, such as time.Now().UnixNano().
|
||||
// Typically a non-fixed seed should be used, such as Uint64(), Uint64().
|
||||
// Using a fixed seed will produce the same output on every run.
|
||||
r := rand.New(rand.NewSource(99))
|
||||
r := rand.New(rand.NewPCG(1, 2))
|
||||
|
||||
// The tabwriter here helps us generate aligned output.
|
||||
w := tabwriter.NewWriter(os.Stdout, 1, 1, 1, ' ', 0)
|
||||
@ -83,17 +83,17 @@ func Example_rand() {
|
||||
// Perm generates a random permutation of the numbers [0, n).
|
||||
show("Perm", r.Perm(5), r.Perm(5), r.Perm(5))
|
||||
// Output:
|
||||
// Float32 0.73793465 0.38461488 0.9940225
|
||||
// Float64 0.6919607852308565 0.29140004584133117 0.2262092163027547
|
||||
// ExpFloat64 0.27263589649304043 1.3214739789908194 2.223639057715668
|
||||
// NormFloat64 -0.09361151905162404 -1.3531915625472757 0.03212053591352371
|
||||
// Int32 1824388269 1817075958 91420417
|
||||
// Int64 3546343826724305832 5724354148158589552 5239846799706671610
|
||||
// Uint32 1380114714 2295813601 961197529
|
||||
// IntN(10) 8 4 5
|
||||
// Int32N(10) 1 8 5
|
||||
// Int64N(10) 4 2 6
|
||||
// Perm [0 2 4 3 1] [0 4 2 3 1] [2 1 3 0 4]
|
||||
// Float32 0.95955694 0.8076733 0.8135684
|
||||
// Float64 0.4297927436037299 0.797802349388613 0.3883664855410056
|
||||
// ExpFloat64 0.43463410545541104 0.5513632046504593 0.7426404617374481
|
||||
// NormFloat64 -0.9303318111676635 -0.04750789419852852 0.22248301107582735
|
||||
// Int32 2020777787 260808523 851126509
|
||||
// Int64 5231057920893523323 4257872588489500903 158397175702351138
|
||||
// Uint32 314478343 1418758728 208955345
|
||||
// IntN(10) 6 2 0
|
||||
// Int32N(10) 3 7 7
|
||||
// Int64N(10) 8 9 4
|
||||
// Perm [0 3 1 4 2] [4 1 2 0 3] [4 3 2 0 1]
|
||||
}
|
||||
|
||||
func ExamplePerm() {
|
||||
|
@ -1,89 +0,0 @@
|
||||
// Copyright 2009 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build ignore
|
||||
|
||||
// This program computes the value of rngCooked in rng.go,
|
||||
// which is used for seeding all instances of rand.Source.
|
||||
// a 64bit and a 63bit version of the array is printed to
|
||||
// the standard output.
|
||||
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
const (
|
||||
length = 607
|
||||
tap = 273
|
||||
mask = (1 << 63) - 1
|
||||
a = 48271
|
||||
m = (1 << 31) - 1
|
||||
q = 44488
|
||||
r = 3399
|
||||
)
|
||||
|
||||
var (
|
||||
rngVec [length]int64
|
||||
rngTap, rngFeed int
|
||||
)
|
||||
|
||||
func seedrand(x int32) int32 {
|
||||
hi := x / q
|
||||
lo := x % q
|
||||
x = a*lo - r*hi
|
||||
if x < 0 {
|
||||
x += m
|
||||
}
|
||||
return x
|
||||
}
|
||||
|
||||
func srand(seed int32) {
|
||||
rngTap = 0
|
||||
rngFeed = length - tap
|
||||
seed %= m
|
||||
if seed < 0 {
|
||||
seed += m
|
||||
} else if seed == 0 {
|
||||
seed = 89482311
|
||||
}
|
||||
x := seed
|
||||
for i := -20; i < length; i++ {
|
||||
x = seedrand(x)
|
||||
if i >= 0 {
|
||||
var u int64
|
||||
u = int64(x) << 20
|
||||
x = seedrand(x)
|
||||
u ^= int64(x) << 10
|
||||
x = seedrand(x)
|
||||
u ^= int64(x)
|
||||
rngVec[i] = u
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func vrand() int64 {
|
||||
rngTap--
|
||||
if rngTap < 0 {
|
||||
rngTap += length
|
||||
}
|
||||
rngFeed--
|
||||
if rngFeed < 0 {
|
||||
rngFeed += length
|
||||
}
|
||||
x := (rngVec[rngFeed] + rngVec[rngTap])
|
||||
rngVec[rngFeed] = x
|
||||
return x
|
||||
}
|
||||
|
||||
func main() {
|
||||
srand(1)
|
||||
for i := uint64(0); i < 7.8e12; i++ {
|
||||
vrand()
|
||||
}
|
||||
fmt.Printf("rngVec after 7.8e12 calls to vrand:\n%#v\n", rngVec)
|
||||
for i := range rngVec {
|
||||
rngVec[i] &= mask
|
||||
}
|
||||
fmt.Printf("lower 63bit of rngVec after 7.8e12 calls to vrand:\n%#v\n", rngVec)
|
||||
}
|
@ -30,20 +30,6 @@ type Source interface {
|
||||
Uint64() uint64
|
||||
}
|
||||
|
||||
// NewSource returns a new pseudo-random Source seeded with the given value.
|
||||
// Unlike the default Source used by top-level functions, this source is not
|
||||
// safe for concurrent use by multiple goroutines.
|
||||
// The returned Source implements Source64.
|
||||
func NewSource(seed int64) Source {
|
||||
return newSource(seed)
|
||||
}
|
||||
|
||||
func newSource(seed int64) *rngSource {
|
||||
var rng rngSource
|
||||
rng.Seed(seed)
|
||||
return &rng
|
||||
}
|
||||
|
||||
// A Rand is a source of random numbers.
|
||||
type Rand struct {
|
||||
src Source
|
||||
@ -273,7 +259,7 @@ func fastrand64() uint64
|
||||
type fastSource struct{}
|
||||
|
||||
func (*fastSource) Int64() int64 {
|
||||
return int64(fastrand64() & rngMask)
|
||||
return int64(fastrand64() << 1 >> 1)
|
||||
}
|
||||
|
||||
func (*fastSource) Uint64() uint64 {
|
||||
|
@ -46,7 +46,7 @@ func nearEqual(a, b, closeEnough, maxError float64) bool {
|
||||
return absDiff/max(math.Abs(a), math.Abs(b)) < maxError
|
||||
}
|
||||
|
||||
var testSeeds = []int64{1, 1754801282, 1698661970, 1550503961}
|
||||
var testSeeds = []uint64{1, 1754801282, 1698661970, 1550503961}
|
||||
|
||||
// checkSimilarDistribution returns success if the mean and stddev of the
|
||||
// two statsResults are similar.
|
||||
@ -104,8 +104,8 @@ func checkSampleSliceDistributions(t *testing.T, samples []float64, nslices int,
|
||||
// Normal distribution tests
|
||||
//
|
||||
|
||||
func generateNormalSamples(nsamples int, mean, stddev float64, seed int64) []float64 {
|
||||
r := New(NewSource(seed))
|
||||
func generateNormalSamples(nsamples int, mean, stddev float64, seed uint64) []float64 {
|
||||
r := New(NewPCG(seed, seed))
|
||||
samples := make([]float64, nsamples)
|
||||
for i := range samples {
|
||||
samples[i] = r.NormFloat64()*stddev + mean
|
||||
@ -113,7 +113,7 @@ func generateNormalSamples(nsamples int, mean, stddev float64, seed int64) []flo
|
||||
return samples
|
||||
}
|
||||
|
||||
func testNormalDistribution(t *testing.T, nsamples int, mean, stddev float64, seed int64) {
|
||||
func testNormalDistribution(t *testing.T, nsamples int, mean, stddev float64, seed uint64) {
|
||||
//fmt.Printf("testing nsamples=%v mean=%v stddev=%v seed=%v\n", nsamples, mean, stddev, seed);
|
||||
|
||||
samples := generateNormalSamples(nsamples, mean, stddev, seed)
|
||||
@ -161,8 +161,8 @@ func TestNonStandardNormalValues(t *testing.T) {
|
||||
// Exponential distribution tests
|
||||
//
|
||||
|
||||
func generateExponentialSamples(nsamples int, rate float64, seed int64) []float64 {
|
||||
r := New(NewSource(seed))
|
||||
func generateExponentialSamples(nsamples int, rate float64, seed uint64) []float64 {
|
||||
r := New(NewPCG(seed, seed))
|
||||
samples := make([]float64, nsamples)
|
||||
for i := range samples {
|
||||
samples[i] = r.ExpFloat64() / rate
|
||||
@ -170,7 +170,7 @@ func generateExponentialSamples(nsamples int, rate float64, seed int64) []float6
|
||||
return samples
|
||||
}
|
||||
|
||||
func testExponentialDistribution(t *testing.T, nsamples int, rate float64, seed int64) {
|
||||
func testExponentialDistribution(t *testing.T, nsamples int, rate float64, seed uint64) {
|
||||
//fmt.Printf("testing nsamples=%v rate=%v seed=%v\n", nsamples, rate, seed);
|
||||
|
||||
mean := 1 / rate
|
||||
@ -398,7 +398,7 @@ func encodePerm(s []int) int {
|
||||
|
||||
// TestUniformFactorial tests several ways of generating a uniform value in [0, n!).
|
||||
func TestUniformFactorial(t *testing.T) {
|
||||
r := New(NewSource(testSeeds[0]))
|
||||
r := New(NewPCG(1, 2))
|
||||
top := 6
|
||||
if testing.Short() {
|
||||
top = 3
|
||||
@ -436,8 +436,8 @@ func TestUniformFactorial(t *testing.T) {
|
||||
// See https://en.wikipedia.org/wiki/Pearson%27s_chi-squared_test and
|
||||
// https://www.johndcook.com/Beautiful_Testing_ch10.pdf.
|
||||
nsamples := 10 * nfact
|
||||
if nsamples < 500 {
|
||||
nsamples = 500
|
||||
if nsamples < 1000 {
|
||||
nsamples = 1000
|
||||
}
|
||||
samples := make([]float64, nsamples)
|
||||
for i := range samples {
|
||||
@ -476,11 +476,11 @@ func TestUniformFactorial(t *testing.T) {
|
||||
var Sink uint64
|
||||
|
||||
func testRand() *Rand {
|
||||
return New(NewSource(1))
|
||||
return New(NewPCG(1, 2))
|
||||
}
|
||||
|
||||
func BenchmarkSourceUint64(b *testing.B) {
|
||||
s := NewSource(1)
|
||||
s := NewPCG(1, 2)
|
||||
var t uint64
|
||||
for n := b.N; n > 0; n-- {
|
||||
t += s.Uint64()
|
||||
|
@ -33,7 +33,7 @@ func TestRegress(t *testing.T) {
|
||||
var uint64s = []uint64{1, 10, 32, 1 << 20, 1<<20 + 1, 1000000000, 1 << 30, 1<<31 - 2, 1<<31 - 1, 1000000000000000000, 1 << 60, 1<<63 - 2, 1<<63 - 1, 1<<64 - 2, 1<<64 - 1}
|
||||
var permSizes = []int{0, 1, 5, 8, 9, 10, 16}
|
||||
|
||||
n := reflect.TypeOf(New(NewSource(1))).NumMethod()
|
||||
n := reflect.TypeOf(New(NewPCG(1, 2))).NumMethod()
|
||||
p := 0
|
||||
var buf bytes.Buffer
|
||||
if *update {
|
||||
@ -43,7 +43,7 @@ func TestRegress(t *testing.T) {
|
||||
if *update && i > 0 {
|
||||
fmt.Fprintf(&buf, "\n")
|
||||
}
|
||||
r := New(NewSource(1))
|
||||
r := New(NewPCG(1, 2))
|
||||
rv := reflect.ValueOf(r)
|
||||
m := rv.Type().Method(i)
|
||||
mv := rv.Method(i)
|
||||
@ -225,339 +225,339 @@ func replace(t *testing.T, file string, new []byte) {
|
||||
}
|
||||
|
||||
var regressGolden = []any{
|
||||
float64(0.018945741402288857), // ExpFloat64()
|
||||
float64(0.13829043737893842), // ExpFloat64()
|
||||
float64(1.1409883497761604), // ExpFloat64()
|
||||
float64(1.2449542292186253), // ExpFloat64()
|
||||
float64(0.4849966704675476), // ExpFloat64()
|
||||
float64(0.08948056191408837), // ExpFloat64()
|
||||
float64(0.41380878045769276), // ExpFloat64()
|
||||
float64(0.31325729628567145), // ExpFloat64()
|
||||
float64(0.23118058048615886), // ExpFloat64()
|
||||
float64(0.2090943007446), // ExpFloat64()
|
||||
float64(2.6861652769471456), // ExpFloat64()
|
||||
float64(1.3811947596783387), // ExpFloat64()
|
||||
float64(1.5595976199841015), // ExpFloat64()
|
||||
float64(2.3469708688771744), // ExpFloat64()
|
||||
float64(0.5882760784580738), // ExpFloat64()
|
||||
float64(0.33463787922271115), // ExpFloat64()
|
||||
float64(0.8799304551478242), // ExpFloat64()
|
||||
float64(1.616532211418378), // ExpFloat64()
|
||||
float64(0.09548420514080316), // ExpFloat64()
|
||||
float64(2.448910012295588), // ExpFloat64()
|
||||
float64(0.5931317151369719), // ExpFloat64()
|
||||
float64(0.0680034588807843), // ExpFloat64()
|
||||
float64(0.036496967459790364), // ExpFloat64()
|
||||
float64(2.460335459645379), // ExpFloat64()
|
||||
float64(1.5792300208419903), // ExpFloat64()
|
||||
float64(0.9149501499404387), // ExpFloat64()
|
||||
float64(0.43463410545541104), // ExpFloat64()
|
||||
float64(0.5513632046504593), // ExpFloat64()
|
||||
float64(0.7426404617374481), // ExpFloat64()
|
||||
float64(1.2334925132631804), // ExpFloat64()
|
||||
float64(0.892529142200442), // ExpFloat64()
|
||||
float64(0.21508763681487764), // ExpFloat64()
|
||||
float64(1.0208588200798545), // ExpFloat64()
|
||||
float64(0.7650739736831382), // ExpFloat64()
|
||||
float64(0.7772788529257701), // ExpFloat64()
|
||||
float64(1.102732861281323), // ExpFloat64()
|
||||
float64(0.6982243043885805), // ExpFloat64()
|
||||
float64(0.4981788638202421), // ExpFloat64()
|
||||
float64(0.15806532306947937), // ExpFloat64()
|
||||
float64(0.9419163802459202), // ExpFloat64()
|
||||
|
||||
float32(0.39651686), // Float32()
|
||||
float32(0.38516325), // Float32()
|
||||
float32(0.06368679), // Float32()
|
||||
float32(0.027415931), // Float32()
|
||||
float32(0.3535996), // Float32()
|
||||
float32(0.9133533), // Float32()
|
||||
float32(0.40153843), // Float32()
|
||||
float32(0.034464598), // Float32()
|
||||
float32(0.4120984), // Float32()
|
||||
float32(0.51671815), // Float32()
|
||||
float32(0.9472164), // Float32()
|
||||
float32(0.14591497), // Float32()
|
||||
float32(0.42577565), // Float32()
|
||||
float32(0.7241202), // Float32()
|
||||
float32(0.7114463), // Float32()
|
||||
float32(0.01790011), // Float32()
|
||||
float32(0.22837132), // Float32()
|
||||
float32(0.5170377), // Float32()
|
||||
float32(0.9228385), // Float32()
|
||||
float32(0.9747907), // Float32()
|
||||
float32(0.95955694), // Float32()
|
||||
float32(0.8076733), // Float32()
|
||||
float32(0.8135684), // Float32()
|
||||
float32(0.92872405), // Float32()
|
||||
float32(0.97472525), // Float32()
|
||||
float32(0.5485458), // Float32()
|
||||
float32(0.97740936), // Float32()
|
||||
float32(0.042272687), // Float32()
|
||||
float32(0.99663067), // Float32()
|
||||
float32(0.035181105), // Float32()
|
||||
float32(0.45059562), // Float32()
|
||||
float32(0.86597633), // Float32()
|
||||
float32(0.8954844), // Float32()
|
||||
float32(0.090798736), // Float32()
|
||||
float32(0.46218646), // Float32()
|
||||
float32(0.5955118), // Float32()
|
||||
float32(0.08985227), // Float32()
|
||||
float32(0.19820237), // Float32()
|
||||
float32(0.7443699), // Float32()
|
||||
float32(0.56461), // Float32()
|
||||
|
||||
float64(0.17213489113047786), // Float64()
|
||||
float64(0.0813061580926816), // Float64()
|
||||
float64(0.5094944957341486), // Float64()
|
||||
float64(0.2193276794677107), // Float64()
|
||||
float64(0.8287970009760902), // Float64()
|
||||
float64(0.30682661592006877), // Float64()
|
||||
float64(0.21230767869565503), // Float64()
|
||||
float64(0.2757168463782187), // Float64()
|
||||
float64(0.2967873684321951), // Float64()
|
||||
float64(0.13374523933395033), // Float64()
|
||||
float64(0.5777315861149934), // Float64()
|
||||
float64(0.16732005385910476), // Float64()
|
||||
float64(0.40620552435192425), // Float64()
|
||||
float64(0.7929618428784644), // Float64()
|
||||
float64(0.691570514257735), // Float64()
|
||||
float64(0.14320118008134408), // Float64()
|
||||
float64(0.8269708087758376), // Float64()
|
||||
float64(0.13630191289931604), // Float64()
|
||||
float64(0.38270814230149663), // Float64()
|
||||
float64(0.7983258549906352), // Float64()
|
||||
float64(0.6764556596678251), // Float64()
|
||||
float64(0.4613862177205994), // Float64()
|
||||
float64(0.5085473976760264), // Float64()
|
||||
float64(0.4297927436037299), // Float64()
|
||||
float64(0.797802349388613), // Float64()
|
||||
float64(0.3883664855410056), // Float64()
|
||||
float64(0.8192750264193612), // Float64()
|
||||
float64(0.3381816951746133), // Float64()
|
||||
float64(0.9730458047755973), // Float64()
|
||||
float64(0.281449117585586), // Float64()
|
||||
float64(0.6047654075331631), // Float64()
|
||||
float64(0.9278107175107462), // Float64()
|
||||
float64(0.16387541502137226), // Float64()
|
||||
float64(0.7263900707339023), // Float64()
|
||||
float64(0.6974917552729882), // Float64()
|
||||
float64(0.7640946923790318), // Float64()
|
||||
float64(0.7188183661358182), // Float64()
|
||||
float64(0.5856191500346635), // Float64()
|
||||
float64(0.9549597149363428), // Float64()
|
||||
float64(0.5168804691962643), // Float64()
|
||||
|
||||
int64(5577006791947779410), // Int()
|
||||
int64(8674665223082153551), // Int()
|
||||
int64(6129484611666145821), // Int()
|
||||
int64(4037200794235010051), // Int()
|
||||
int64(3916589616287113937), // Int()
|
||||
int64(6334824724549167320), // Int()
|
||||
int64(605394647632969758), // Int()
|
||||
int64(1443635317331776148), // Int()
|
||||
int64(894385949183117216), // Int()
|
||||
int64(2775422040480279449), // Int()
|
||||
int64(4751997750760398084), // Int()
|
||||
int64(7504504064263669287), // Int()
|
||||
int64(1976235410884491574), // Int()
|
||||
int64(3510942875414458836), // Int()
|
||||
int64(2933568871211445515), // Int()
|
||||
int64(4324745483838182873), // Int()
|
||||
int64(2610529275472644968), // Int()
|
||||
int64(2703387474910584091), // Int()
|
||||
int64(6263450610539110790), // Int()
|
||||
int64(2015796113853353331), // Int()
|
||||
int64(4969059760275911952), // Int()
|
||||
int64(2147869220224756844), // Int()
|
||||
int64(5246770554000605320), // Int()
|
||||
int64(5471241176507662746), // Int()
|
||||
int64(4321634407747778896), // Int()
|
||||
int64(760102831717374652), // Int()
|
||||
int64(9221744211007427193), // Int()
|
||||
int64(8289669384274456462), // Int()
|
||||
int64(2449715415482412441), // Int()
|
||||
int64(3389241988064777392), // Int()
|
||||
int64(2986830195847294191), // Int()
|
||||
int64(8204908297817606218), // Int()
|
||||
int64(8134976985547166651), // Int()
|
||||
int64(2240328155279531677), // Int()
|
||||
int64(7311121042813227358), // Int()
|
||||
int64(5231057920893523323), // Int()
|
||||
int64(4257872588489500903), // Int()
|
||||
int64(158397175702351138), // Int()
|
||||
int64(1350674201389090105), // Int()
|
||||
int64(6093522341581845358), // Int()
|
||||
|
||||
int32(649249040), // Int32()
|
||||
int32(1009863943), // Int32()
|
||||
int32(1787307747), // Int32()
|
||||
int32(1543733853), // Int32()
|
||||
int32(455951040), // Int32()
|
||||
int32(737470659), // Int32()
|
||||
int32(1144219036), // Int32()
|
||||
int32(1241803094), // Int32()
|
||||
int32(104120228), // Int32()
|
||||
int32(1396843474), // Int32()
|
||||
int32(553205347), // Int32()
|
||||
int32(873639255), // Int32()
|
||||
int32(1303805905), // Int32()
|
||||
int32(408727544), // Int32()
|
||||
int32(1415254188), // Int32()
|
||||
int32(503466637), // Int32()
|
||||
int32(1377647429), // Int32()
|
||||
int32(1388457546), // Int32()
|
||||
int32(729161618), // Int32()
|
||||
int32(1308411377), // Int32()
|
||||
int32(1652216515), // Int32()
|
||||
int32(1323786710), // Int32()
|
||||
int32(1684546306), // Int32()
|
||||
int32(1710678126), // Int32()
|
||||
int32(503104460), // Int32()
|
||||
int32(88487615), // Int32()
|
||||
int32(1073552320), // Int32()
|
||||
int32(965044529), // Int32()
|
||||
int32(285184408), // Int32()
|
||||
int32(394559696), // Int32()
|
||||
int32(1421454622), // Int32()
|
||||
int32(955177040), // Int32()
|
||||
int32(2020777787), // Int32()
|
||||
int32(260808523), // Int32()
|
||||
int32(851126509), // Int32()
|
||||
int32(1682717115), // Int32()
|
||||
int32(1569423431), // Int32()
|
||||
int32(1092181682), // Int32()
|
||||
int32(157239171), // Int32()
|
||||
int32(709379364), // Int32()
|
||||
|
||||
int32(0), // Int32N(1)
|
||||
int32(4), // Int32N(10)
|
||||
int32(29), // Int32N(32)
|
||||
int32(883715), // Int32N(1048576)
|
||||
int32(222632), // Int32N(1048577)
|
||||
int32(343411536), // Int32N(1000000000)
|
||||
int32(957743134), // Int32N(1073741824)
|
||||
int32(1241803092), // Int32N(2147483646)
|
||||
int32(104120228), // Int32N(2147483647)
|
||||
int32(0), // Int32N(1)
|
||||
int32(2), // Int32N(10)
|
||||
int32(7), // Int32N(32)
|
||||
int32(96566), // Int32N(1048576)
|
||||
int32(199574), // Int32N(1048577)
|
||||
int32(659029087), // Int32N(1000000000)
|
||||
int32(606492121), // Int32N(1073741824)
|
||||
int32(1377647428), // Int32N(2147483646)
|
||||
int32(1388457546), // Int32N(2147483647)
|
||||
int32(0), // Int32N(1)
|
||||
int32(6), // Int32N(10)
|
||||
int32(8), // Int32N(32)
|
||||
int32(704922), // Int32N(1048576)
|
||||
int32(245656), // Int32N(1048577)
|
||||
int32(41205257), // Int32N(1000000000)
|
||||
int32(43831929), // Int32N(1073741824)
|
||||
int32(965044528), // Int32N(2147483646)
|
||||
int32(285184408), // Int32N(2147483647)
|
||||
int32(0), // Int32N(1)
|
||||
int32(6), // Int32N(10)
|
||||
int32(10), // Int32N(32)
|
||||
int32(283579), // Int32N(1048576)
|
||||
int32(127348), // Int32N(1048577)
|
||||
int32(396336665), // Int32N(1000000000)
|
||||
int32(911873403), // Int32N(1073741824)
|
||||
int32(1569423430), // Int32N(2147483646)
|
||||
int32(1092181681), // Int32N(2147483647)
|
||||
int32(0), // Int32N(1)
|
||||
int32(3), // Int32N(10)
|
||||
|
||||
int64(5577006791947779410), // Int64()
|
||||
int64(8674665223082153551), // Int64()
|
||||
int64(6129484611666145821), // Int64()
|
||||
int64(4037200794235010051), // Int64()
|
||||
int64(3916589616287113937), // Int64()
|
||||
int64(6334824724549167320), // Int64()
|
||||
int64(605394647632969758), // Int64()
|
||||
int64(1443635317331776148), // Int64()
|
||||
int64(894385949183117216), // Int64()
|
||||
int64(2775422040480279449), // Int64()
|
||||
int64(4751997750760398084), // Int64()
|
||||
int64(7504504064263669287), // Int64()
|
||||
int64(1976235410884491574), // Int64()
|
||||
int64(3510942875414458836), // Int64()
|
||||
int64(2933568871211445515), // Int64()
|
||||
int64(4324745483838182873), // Int64()
|
||||
int64(2610529275472644968), // Int64()
|
||||
int64(2703387474910584091), // Int64()
|
||||
int64(6263450610539110790), // Int64()
|
||||
int64(2015796113853353331), // Int64()
|
||||
int64(4969059760275911952), // Int64()
|
||||
int64(2147869220224756844), // Int64()
|
||||
int64(5246770554000605320), // Int64()
|
||||
int64(5471241176507662746), // Int64()
|
||||
int64(4321634407747778896), // Int64()
|
||||
int64(760102831717374652), // Int64()
|
||||
int64(9221744211007427193), // Int64()
|
||||
int64(8289669384274456462), // Int64()
|
||||
int64(2449715415482412441), // Int64()
|
||||
int64(3389241988064777392), // Int64()
|
||||
int64(2986830195847294191), // Int64()
|
||||
int64(8204908297817606218), // Int64()
|
||||
int64(8134976985547166651), // Int64()
|
||||
int64(2240328155279531677), // Int64()
|
||||
int64(7311121042813227358), // Int64()
|
||||
int64(5231057920893523323), // Int64()
|
||||
int64(4257872588489500903), // Int64()
|
||||
int64(158397175702351138), // Int64()
|
||||
int64(1350674201389090105), // Int64()
|
||||
int64(6093522341581845358), // Int64()
|
||||
|
||||
int64(0), // Int64N(1)
|
||||
int64(4), // Int64N(10)
|
||||
int64(29), // Int64N(32)
|
||||
int64(883715), // Int64N(1048576)
|
||||
int64(222632), // Int64N(1048577)
|
||||
int64(343411536), // Int64N(1000000000)
|
||||
int64(957743134), // Int64N(1073741824)
|
||||
int64(1241803092), // Int64N(2147483646)
|
||||
int64(104120228), // Int64N(2147483647)
|
||||
int64(650455930292643530), // Int64N(1000000000000000000)
|
||||
int64(140311732333010180), // Int64N(1152921504606846976)
|
||||
int64(3752252032131834642), // Int64N(9223372036854775806)
|
||||
int64(5599803723869633690), // Int64N(9223372036854775807)
|
||||
int64(0), // Int64N(1)
|
||||
int64(6), // Int64N(10)
|
||||
int64(25), // Int64N(32)
|
||||
int64(920424), // Int64N(1048576)
|
||||
int64(677958), // Int64N(1048577)
|
||||
int64(339542337), // Int64N(1000000000)
|
||||
int64(701992307), // Int64N(1073741824)
|
||||
int64(8), // Int64N(32)
|
||||
int64(704922), // Int64N(1048576)
|
||||
int64(245656), // Int64N(1048577)
|
||||
int64(41205257), // Int64N(1000000000)
|
||||
int64(43831929), // Int64N(1073741824)
|
||||
int64(965044528), // Int64N(2147483646)
|
||||
int64(285184408), // Int64N(2147483647)
|
||||
int64(183731176326946086), // Int64N(1000000000000000000)
|
||||
int64(680987186633600239), // Int64N(1152921504606846976)
|
||||
int64(4102454148908803108), // Int64N(9223372036854775806)
|
||||
int64(8679174511200971228), // Int64N(9223372036854775807)
|
||||
int64(0), // Int64N(1)
|
||||
int64(3), // Int64N(10)
|
||||
int64(27), // Int64N(32)
|
||||
int64(665831), // Int64N(1048576)
|
||||
int64(533292), // Int64N(1048577)
|
||||
int64(73220195), // Int64N(1000000000)
|
||||
int64(686060398), // Int64N(1073741824)
|
||||
|
||||
int64(0), // IntN(1)
|
||||
int64(4), // IntN(10)
|
||||
int64(29), // IntN(32)
|
||||
int64(883715), // IntN(1048576)
|
||||
int64(222632), // IntN(1048577)
|
||||
int64(343411536), // IntN(1000000000)
|
||||
int64(957743134), // IntN(1073741824)
|
||||
int64(1241803092), // IntN(2147483646)
|
||||
int64(104120228), // IntN(2147483647)
|
||||
int64(650455930292643530), // IntN(1000000000000000000)
|
||||
int64(140311732333010180), // IntN(1152921504606846976)
|
||||
int64(3752252032131834642), // IntN(9223372036854775806)
|
||||
int64(5599803723869633690), // IntN(9223372036854775807)
|
||||
int64(0), // IntN(1)
|
||||
int64(6), // IntN(10)
|
||||
int64(25), // IntN(32)
|
||||
int64(920424), // IntN(1048576)
|
||||
int64(677958), // IntN(1048577)
|
||||
int64(339542337), // IntN(1000000000)
|
||||
int64(701992307), // IntN(1073741824)
|
||||
int64(8), // IntN(32)
|
||||
int64(704922), // IntN(1048576)
|
||||
int64(245656), // IntN(1048577)
|
||||
int64(41205257), // IntN(1000000000)
|
||||
int64(43831929), // IntN(1073741824)
|
||||
int64(965044528), // IntN(2147483646)
|
||||
int64(285184408), // IntN(2147483647)
|
||||
int64(183731176326946086), // IntN(1000000000000000000)
|
||||
int64(680987186633600239), // IntN(1152921504606846976)
|
||||
int64(4102454148908803108), // IntN(9223372036854775806)
|
||||
int64(8679174511200971228), // IntN(9223372036854775807)
|
||||
int64(0), // IntN(1)
|
||||
int64(3), // IntN(10)
|
||||
int64(27), // IntN(32)
|
||||
int64(665831), // IntN(1048576)
|
||||
int64(533292), // IntN(1048577)
|
||||
int64(73220195), // IntN(1000000000)
|
||||
int64(686060398), // IntN(1073741824)
|
||||
|
||||
float64(0.06909351197715208), // NormFloat64()
|
||||
float64(0.5938704963270934), // NormFloat64()
|
||||
float64(1.306028863617345), // NormFloat64()
|
||||
float64(1.4117443127537266), // NormFloat64()
|
||||
float64(0.15696085092285333), // NormFloat64()
|
||||
float64(1.360954184661658), // NormFloat64()
|
||||
float64(0.34312984093649135), // NormFloat64()
|
||||
float64(0.7340067314938814), // NormFloat64()
|
||||
float64(0.22135434353553696), // NormFloat64()
|
||||
float64(-0.15741313389982836), // NormFloat64()
|
||||
float64(-1.080896970111088), // NormFloat64()
|
||||
float64(-0.6107370548788273), // NormFloat64()
|
||||
float64(-2.3550050260853643), // NormFloat64()
|
||||
float64(1.8363976597396832), // NormFloat64()
|
||||
float64(-0.7167650947520989), // NormFloat64()
|
||||
float64(0.6860847654927735), // NormFloat64()
|
||||
float64(0.3403802538398155), // NormFloat64()
|
||||
float64(-1.3884780626234523), // NormFloat64()
|
||||
float64(0.14097321427512907), // NormFloat64()
|
||||
float64(-1.032800550788109), // NormFloat64()
|
||||
float64(0.37944549835531083), // NormFloat64()
|
||||
float64(0.07473804659119399), // NormFloat64()
|
||||
float64(0.20006841200604142), // NormFloat64()
|
||||
float64(-1.1253144115495104), // NormFloat64()
|
||||
float64(-0.4005883316435388), // NormFloat64()
|
||||
float64(-3.0853771402394736), // NormFloat64()
|
||||
float64(1.932330243076978), // NormFloat64()
|
||||
float64(1.726131393719264), // NormFloat64()
|
||||
float64(-0.11707238034168332), // NormFloat64()
|
||||
float64(-0.9303318111676635), // NormFloat64()
|
||||
float64(-0.04750789419852852), // NormFloat64()
|
||||
float64(0.22248301107582735), // NormFloat64()
|
||||
float64(-1.83630520614272), // NormFloat64()
|
||||
float64(0.7259521217919809), // NormFloat64()
|
||||
float64(0.8806882871913041), // NormFloat64()
|
||||
float64(-1.5022903484270484), // NormFloat64()
|
||||
float64(0.5972577266810571), // NormFloat64()
|
||||
float64(1.5631937339973658), // NormFloat64()
|
||||
float64(-0.3841235370075905), // NormFloat64()
|
||||
float64(-0.2967295854430667), // NormFloat64()
|
||||
|
||||
[]int{}, // Perm(0)
|
||||
[]int{0}, // Perm(1)
|
||||
[]int{0, 4, 2, 3, 1}, // Perm(5)
|
||||
[]int{4, 5, 7, 0, 6, 3, 2, 1}, // Perm(8)
|
||||
[]int{2, 5, 4, 0, 7, 8, 1, 6, 3}, // Perm(9)
|
||||
[]int{9, 8, 7, 1, 3, 2, 5, 4, 0, 6}, // Perm(10)
|
||||
[]int{1, 5, 8, 11, 14, 2, 7, 10, 15, 9, 13, 6, 0, 3, 12, 4}, // Perm(16)
|
||||
[]int{1, 4, 2, 0, 3}, // Perm(5)
|
||||
[]int{4, 3, 6, 1, 5, 2, 7, 0}, // Perm(8)
|
||||
[]int{6, 5, 1, 8, 7, 2, 0, 3, 4}, // Perm(9)
|
||||
[]int{9, 4, 2, 5, 6, 8, 1, 7, 0, 3}, // Perm(10)
|
||||
[]int{5, 9, 3, 1, 4, 2, 10, 7, 15, 11, 0, 14, 13, 8, 6, 12}, // Perm(16)
|
||||
[]int{}, // Perm(0)
|
||||
[]int{0}, // Perm(1)
|
||||
[]int{4, 1, 2, 0, 3}, // Perm(5)
|
||||
[]int{7, 0, 3, 5, 4, 1, 2, 6}, // Perm(8)
|
||||
[]int{6, 7, 1, 2, 0, 5, 8, 3, 4}, // Perm(9)
|
||||
[]int{7, 2, 8, 6, 1, 5, 9, 0, 3, 4}, // Perm(10)
|
||||
[]int{11, 0, 5, 1, 12, 4, 13, 9, 7, 2, 15, 10, 8, 14, 6, 3}, // Perm(16)
|
||||
[]int{4, 2, 1, 3, 0}, // Perm(5)
|
||||
[]int{0, 2, 3, 1, 5, 4, 6, 7}, // Perm(8)
|
||||
[]int{2, 0, 8, 3, 4, 7, 6, 5, 1}, // Perm(9)
|
||||
[]int{0, 6, 5, 3, 8, 4, 1, 2, 9, 7}, // Perm(10)
|
||||
[]int{9, 14, 4, 11, 13, 8, 0, 6, 2, 12, 3, 7, 1, 10, 5, 15}, // Perm(16)
|
||||
[]int{}, // Perm(0)
|
||||
[]int{0}, // Perm(1)
|
||||
[]int{2, 4, 0, 3, 1}, // Perm(5)
|
||||
[]int{4, 2, 5, 0, 6, 3, 1, 7}, // Perm(8)
|
||||
[]int{3, 2, 8, 6, 5, 7, 1, 4, 0}, // Perm(9)
|
||||
[]int{2, 0, 7, 5, 6, 1, 8, 3, 4, 9}, // Perm(10)
|
||||
[]int{3, 2, 1, 0, 7, 5, 4, 6}, // Perm(8)
|
||||
[]int{1, 3, 4, 5, 0, 2, 7, 8, 6}, // Perm(9)
|
||||
[]int{1, 8, 4, 7, 2, 6, 5, 9, 0, 3}, // Perm(10)
|
||||
|
||||
uint32(1298498081), // Uint32()
|
||||
uint32(2019727887), // Uint32()
|
||||
uint32(3574615495), // Uint32()
|
||||
uint32(3087467707), // Uint32()
|
||||
uint32(911902081), // Uint32()
|
||||
uint32(1474941318), // Uint32()
|
||||
uint32(2288438073), // Uint32()
|
||||
uint32(2483606188), // Uint32()
|
||||
uint32(208240456), // Uint32()
|
||||
uint32(2793686948), // Uint32()
|
||||
uint32(1106410694), // Uint32()
|
||||
uint32(1747278511), // Uint32()
|
||||
uint32(2607611810), // Uint32()
|
||||
uint32(817455089), // Uint32()
|
||||
uint32(2830508376), // Uint32()
|
||||
uint32(1006933274), // Uint32()
|
||||
uint32(2755294859), // Uint32()
|
||||
uint32(2776915093), // Uint32()
|
||||
uint32(1458323237), // Uint32()
|
||||
uint32(2616822754), // Uint32()
|
||||
uint32(3304433030), // Uint32()
|
||||
uint32(2647573421), // Uint32()
|
||||
uint32(3369092613), // Uint32()
|
||||
uint32(3421356252), // Uint32()
|
||||
uint32(1006208920), // Uint32()
|
||||
uint32(176975231), // Uint32()
|
||||
uint32(2147104640), // Uint32()
|
||||
uint32(1930089058), // Uint32()
|
||||
uint32(570368816), // Uint32()
|
||||
uint32(789119393), // Uint32()
|
||||
uint32(2842909244), // Uint32()
|
||||
uint32(1910354080), // Uint32()
|
||||
uint32(4041555575), // Uint32()
|
||||
uint32(521617046), // Uint32()
|
||||
uint32(1702253018), // Uint32()
|
||||
uint32(3365434230), // Uint32()
|
||||
uint32(3138846863), // Uint32()
|
||||
uint32(2184363364), // Uint32()
|
||||
uint32(314478343), // Uint32()
|
||||
uint32(1418758728), // Uint32()
|
||||
|
||||
uint32(0), // Uint32N(1)
|
||||
uint32(4), // Uint32N(10)
|
||||
uint32(29), // Uint32N(32)
|
||||
uint32(883715), // Uint32N(1048576)
|
||||
uint32(222632), // Uint32N(1048577)
|
||||
uint32(343411536), // Uint32N(1000000000)
|
||||
uint32(957743134), // Uint32N(1073741824)
|
||||
uint32(1241803092), // Uint32N(2147483646)
|
||||
uint32(104120228), // Uint32N(2147483647)
|
||||
uint32(2793686946), // Uint32N(4294967294)
|
||||
uint32(1106410694), // Uint32N(4294967295)
|
||||
uint32(0), // Uint32N(1)
|
||||
uint32(6), // Uint32N(10)
|
||||
uint32(20), // Uint32N(32)
|
||||
uint32(240907), // Uint32N(1048576)
|
||||
uint32(245833), // Uint32N(1048577)
|
||||
uint32(641517075), // Uint32N(1000000000)
|
||||
uint32(340335899), // Uint32N(1073741824)
|
||||
uint32(729161617), // Uint32N(2147483646)
|
||||
uint32(1308411376), // Uint32N(2147483647)
|
||||
uint32(8), // Uint32N(32)
|
||||
uint32(704922), // Uint32N(1048576)
|
||||
uint32(245656), // Uint32N(1048577)
|
||||
uint32(41205257), // Uint32N(1000000000)
|
||||
uint32(43831929), // Uint32N(1073741824)
|
||||
uint32(965044528), // Uint32N(2147483646)
|
||||
uint32(285184408), // Uint32N(2147483647)
|
||||
uint32(789119393), // Uint32N(4294967294)
|
||||
uint32(2842909244), // Uint32N(4294967295)
|
||||
uint32(0), // Uint32N(1)
|
||||
uint32(9), // Uint32N(10)
|
||||
uint32(29), // Uint32N(32)
|
||||
uint32(266590), // Uint32N(1048576)
|
||||
uint32(821640), // Uint32N(1048577)
|
||||
uint32(730819735), // Uint32N(1000000000)
|
||||
uint32(522841378), // Uint32N(1073741824)
|
||||
uint32(157239171), // Uint32N(2147483646)
|
||||
uint32(709379364), // Uint32N(2147483647)
|
||||
|
||||
uint64(5577006791947779410), // Uint64()
|
||||
uint64(8674665223082153551), // Uint64()
|
||||
uint64(15352856648520921629), // Uint64()
|
||||
uint64(13260572831089785859), // Uint64()
|
||||
uint64(3916589616287113937), // Uint64()
|
||||
uint64(6334824724549167320), // Uint64()
|
||||
uint64(9828766684487745566), // Uint64()
|
||||
uint64(10667007354186551956), // Uint64()
|
||||
uint64(894385949183117216), // Uint64()
|
||||
uint64(11998794077335055257), // Uint64()
|
||||
uint64(4751997750760398084), // Uint64()
|
||||
uint64(7504504064263669287), // Uint64()
|
||||
uint64(11199607447739267382), // Uint64()
|
||||
uint64(3510942875414458836), // Uint64()
|
||||
uint64(12156940908066221323), // Uint64()
|
||||
uint64(4324745483838182873), // Uint64()
|
||||
uint64(11833901312327420776), // Uint64()
|
||||
uint64(11926759511765359899), // Uint64()
|
||||
uint64(6263450610539110790), // Uint64()
|
||||
uint64(11239168150708129139), // Uint64()
|
||||
uint64(14192431797130687760), // Uint64()
|
||||
uint64(11371241257079532652), // Uint64()
|
||||
uint64(14470142590855381128), // Uint64()
|
||||
uint64(14694613213362438554), // Uint64()
|
||||
uint64(4321634407747778896), // Uint64()
|
||||
uint64(760102831717374652), // Uint64()
|
||||
uint64(9221744211007427193), // Uint64()
|
||||
uint64(8289669384274456462), // Uint64()
|
||||
uint64(2449715415482412441), // Uint64()
|
||||
uint64(3389241988064777392), // Uint64()
|
||||
uint64(12210202232702069999), // Uint64()
|
||||
uint64(8204908297817606218), // Uint64()
|
||||
uint64(17358349022401942459), // Uint64()
|
||||
uint64(2240328155279531677), // Uint64()
|
||||
uint64(7311121042813227358), // Uint64()
|
||||
uint64(14454429957748299131), // Uint64()
|
||||
uint64(13481244625344276711), // Uint64()
|
||||
uint64(9381769212557126946), // Uint64()
|
||||
uint64(1350674201389090105), // Uint64()
|
||||
uint64(6093522341581845358), // Uint64()
|
||||
|
||||
uint64(0), // Uint64N(1)
|
||||
uint64(4), // Uint64N(10)
|
||||
uint64(29), // Uint64N(32)
|
||||
uint64(883715), // Uint64N(1048576)
|
||||
uint64(222632), // Uint64N(1048577)
|
||||
uint64(343411536), // Uint64N(1000000000)
|
||||
uint64(957743134), // Uint64N(1073741824)
|
||||
uint64(1241803092), // Uint64N(2147483646)
|
||||
uint64(104120228), // Uint64N(2147483647)
|
||||
uint64(650455930292643530), // Uint64N(1000000000000000000)
|
||||
uint64(140311732333010180), // Uint64N(1152921504606846976)
|
||||
uint64(3752252032131834642), // Uint64N(9223372036854775806)
|
||||
uint64(5599803723869633690), // Uint64N(9223372036854775807)
|
||||
uint64(3510942875414458835), // Uint64N(18446744073709551614)
|
||||
uint64(12156940908066221322), // Uint64N(18446744073709551615)
|
||||
uint64(0), // Uint64N(1)
|
||||
uint64(6), // Uint64N(10)
|
||||
uint64(27), // Uint64N(32)
|
||||
uint64(205190), // Uint64N(1048576)
|
||||
uint64(638873), // Uint64N(1048577)
|
||||
uint64(0), // Uint64N(1)
|
||||
uint64(6), // Uint64N(10)
|
||||
uint64(8), // Uint64N(32)
|
||||
uint64(704922), // Uint64N(1048576)
|
||||
uint64(245656), // Uint64N(1048577)
|
||||
uint64(41205257), // Uint64N(1000000000)
|
||||
uint64(43831929), // Uint64N(1073741824)
|
||||
uint64(965044528), // Uint64N(2147483646)
|
||||
uint64(285184408), // Uint64N(2147483647)
|
||||
uint64(183731176326946086), // Uint64N(1000000000000000000)
|
||||
uint64(680987186633600239), // Uint64N(1152921504606846976)
|
||||
uint64(4102454148908803108), // Uint64N(9223372036854775806)
|
||||
uint64(8679174511200971228), // Uint64N(9223372036854775807)
|
||||
uint64(2240328155279531676), // Uint64N(18446744073709551614)
|
||||
uint64(7311121042813227357), // Uint64N(18446744073709551615)
|
||||
uint64(0), // Uint64N(1)
|
||||
uint64(7), // Uint64N(10)
|
||||
uint64(2), // Uint64N(32)
|
||||
uint64(312633), // Uint64N(1048576)
|
||||
uint64(346376), // Uint64N(1048577)
|
||||
|
||||
uint64(0), // UintN(1)
|
||||
uint64(4), // UintN(10)
|
||||
uint64(29), // UintN(32)
|
||||
uint64(883715), // UintN(1048576)
|
||||
uint64(222632), // UintN(1048577)
|
||||
uint64(343411536), // UintN(1000000000)
|
||||
uint64(957743134), // UintN(1073741824)
|
||||
uint64(1241803092), // UintN(2147483646)
|
||||
uint64(104120228), // UintN(2147483647)
|
||||
uint64(650455930292643530), // UintN(1000000000000000000)
|
||||
uint64(140311732333010180), // UintN(1152921504606846976)
|
||||
uint64(3752252032131834642), // UintN(9223372036854775806)
|
||||
uint64(5599803723869633690), // UintN(9223372036854775807)
|
||||
uint64(3510942875414458835), // UintN(18446744073709551614)
|
||||
uint64(12156940908066221322), // UintN(18446744073709551615)
|
||||
uint64(0), // UintN(1)
|
||||
uint64(6), // UintN(10)
|
||||
uint64(27), // UintN(32)
|
||||
uint64(205190), // UintN(1048576)
|
||||
uint64(638873), // UintN(1048577)
|
||||
uint64(0), // UintN(1)
|
||||
uint64(6), // UintN(10)
|
||||
uint64(8), // UintN(32)
|
||||
uint64(704922), // UintN(1048576)
|
||||
uint64(245656), // UintN(1048577)
|
||||
uint64(41205257), // UintN(1000000000)
|
||||
uint64(43831929), // UintN(1073741824)
|
||||
uint64(965044528), // UintN(2147483646)
|
||||
uint64(285184408), // UintN(2147483647)
|
||||
uint64(183731176326946086), // UintN(1000000000000000000)
|
||||
uint64(680987186633600239), // UintN(1152921504606846976)
|
||||
uint64(4102454148908803108), // UintN(9223372036854775806)
|
||||
uint64(8679174511200971228), // UintN(9223372036854775807)
|
||||
uint64(2240328155279531676), // UintN(18446744073709551614)
|
||||
uint64(7311121042813227357), // UintN(18446744073709551615)
|
||||
uint64(0), // UintN(1)
|
||||
uint64(7), // UintN(10)
|
||||
uint64(2), // UintN(32)
|
||||
uint64(312633), // UintN(1048576)
|
||||
uint64(346376), // UintN(1048577)
|
||||
}
|
||||
|
@ -1,252 +0,0 @@
|
||||
// Copyright 2009 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package rand
|
||||
|
||||
/*
|
||||
* Uniform distribution
|
||||
*
|
||||
* algorithm by
|
||||
* DP Mitchell and JA Reeds
|
||||
*/
|
||||
|
||||
const (
|
||||
rngLen = 607
|
||||
rngTap = 273
|
||||
rngMax = 1 << 63
|
||||
rngMask = rngMax - 1
|
||||
int32max = (1 << 31) - 1
|
||||
)
|
||||
|
||||
var (
|
||||
// rngCooked used for seeding. See gen_cooked.go for details.
|
||||
rngCooked [rngLen]int64 = [...]int64{
|
||||
-4181792142133755926, -4576982950128230565, 1395769623340756751, 5333664234075297259,
|
||||
-6347679516498800754, 9033628115061424579, 7143218595135194537, 4812947590706362721,
|
||||
7937252194349799378, 5307299880338848416, 8209348851763925077, -7107630437535961764,
|
||||
4593015457530856296, 8140875735541888011, -5903942795589686782, -603556388664454774,
|
||||
-7496297993371156308, 113108499721038619, 4569519971459345583, -4160538177779461077,
|
||||
-6835753265595711384, -6507240692498089696, 6559392774825876886, 7650093201692370310,
|
||||
7684323884043752161, -8965504200858744418, -2629915517445760644, 271327514973697897,
|
||||
-6433985589514657524, 1065192797246149621, 3344507881999356393, -4763574095074709175,
|
||||
7465081662728599889, 1014950805555097187, -4773931307508785033, -5742262670416273165,
|
||||
2418672789110888383, 5796562887576294778, 4484266064449540171, 3738982361971787048,
|
||||
-4699774852342421385, 10530508058128498, -589538253572429690, -6598062107225984180,
|
||||
8660405965245884302, 10162832508971942, -2682657355892958417, 7031802312784620857,
|
||||
6240911277345944669, 831864355460801054, -1218937899312622917, 2116287251661052151,
|
||||
2202309800992166967, 9161020366945053561, 4069299552407763864, 4936383537992622449,
|
||||
457351505131524928, -8881176990926596454, -6375600354038175299, -7155351920868399290,
|
||||
4368649989588021065, 887231587095185257, -3659780529968199312, -2407146836602825512,
|
||||
5616972787034086048, -751562733459939242, 1686575021641186857, -5177887698780513806,
|
||||
-4979215821652996885, -1375154703071198421, 5632136521049761902, -8390088894796940536,
|
||||
-193645528485698615, -5979788902190688516, -4907000935050298721, -285522056888777828,
|
||||
-2776431630044341707, 1679342092332374735, 6050638460742422078, -2229851317345194226,
|
||||
-1582494184340482199, 5881353426285907985, 812786550756860885, 4541845584483343330,
|
||||
-6497901820577766722, 4980675660146853729, -4012602956251539747, -329088717864244987,
|
||||
-2896929232104691526, 1495812843684243920, -2153620458055647789, 7370257291860230865,
|
||||
-2466442761497833547, 4706794511633873654, -1398851569026877145, 8549875090542453214,
|
||||
-9189721207376179652, -7894453601103453165, 7297902601803624459, 1011190183918857495,
|
||||
-6985347000036920864, 5147159997473910359, -8326859945294252826, 2659470849286379941,
|
||||
6097729358393448602, -7491646050550022124, -5117116194870963097, -896216826133240300,
|
||||
-745860416168701406, 5803876044675762232, -787954255994554146, -3234519180203704564,
|
||||
-4507534739750823898, -1657200065590290694, 505808562678895611, -4153273856159712438,
|
||||
-8381261370078904295, 572156825025677802, 1791881013492340891, 3393267094866038768,
|
||||
-5444650186382539299, 2352769483186201278, -7930912453007408350, -325464993179687389,
|
||||
-3441562999710612272, -6489413242825283295, 5092019688680754699, -227247482082248967,
|
||||
4234737173186232084, 5027558287275472836, 4635198586344772304, -536033143587636457,
|
||||
5907508150730407386, -8438615781380831356, 972392927514829904, -3801314342046600696,
|
||||
-4064951393885491917, -174840358296132583, 2407211146698877100, -1640089820333676239,
|
||||
3940796514530962282, -5882197405809569433, 3095313889586102949, -1818050141166537098,
|
||||
5832080132947175283, 7890064875145919662, 8184139210799583195, -8073512175445549678,
|
||||
-7758774793014564506, -4581724029666783935, 3516491885471466898, -8267083515063118116,
|
||||
6657089965014657519, 5220884358887979358, 1796677326474620641, 5340761970648932916,
|
||||
1147977171614181568, 5066037465548252321, 2574765911837859848, 1085848279845204775,
|
||||
-5873264506986385449, 6116438694366558490, 2107701075971293812, -7420077970933506541,
|
||||
2469478054175558874, -1855128755834809824, -5431463669011098282, -9038325065738319171,
|
||||
-6966276280341336160, 7217693971077460129, -8314322083775271549, 7196649268545224266,
|
||||
-3585711691453906209, -5267827091426810625, 8057528650917418961, -5084103596553648165,
|
||||
-2601445448341207749, -7850010900052094367, 6527366231383600011, 3507654575162700890,
|
||||
9202058512774729859, 1954818376891585542, -2582991129724600103, 8299563319178235687,
|
||||
-5321504681635821435, 7046310742295574065, -2376176645520785576, -7650733936335907755,
|
||||
8850422670118399721, 3631909142291992901, 5158881091950831288, -6340413719511654215,
|
||||
4763258931815816403, 6280052734341785344, -4979582628649810958, 2043464728020827976,
|
||||
-2678071570832690343, 4562580375758598164, 5495451168795427352, -7485059175264624713,
|
||||
553004618757816492, 6895160632757959823, -989748114590090637, 7139506338801360852,
|
||||
-672480814466784139, 5535668688139305547, 2430933853350256242, -3821430778991574732,
|
||||
-1063731997747047009, -3065878205254005442, 7632066283658143750, 6308328381617103346,
|
||||
3681878764086140361, 3289686137190109749, 6587997200611086848, 244714774258135476,
|
||||
-5143583659437639708, 8090302575944624335, 2945117363431356361, -8359047641006034763,
|
||||
3009039260312620700, -793344576772241777, 401084700045993341, -1968749590416080887,
|
||||
4707864159563588614, -3583123505891281857, -3240864324164777915, -5908273794572565703,
|
||||
-3719524458082857382, -5281400669679581926, 8118566580304798074, 3839261274019871296,
|
||||
7062410411742090847, -8481991033874568140, 6027994129690250817, -6725542042704711878,
|
||||
-2971981702428546974, -7854441788951256975, 8809096399316380241, 6492004350391900708,
|
||||
2462145737463489636, -8818543617934476634, -5070345602623085213, -8961586321599299868,
|
||||
-3758656652254704451, -8630661632476012791, 6764129236657751224, -709716318315418359,
|
||||
-3403028373052861600, -8838073512170985897, -3999237033416576341, -2920240395515973663,
|
||||
-2073249475545404416, 368107899140673753, -6108185202296464250, -6307735683270494757,
|
||||
4782583894627718279, 6718292300699989587, 8387085186914375220, 3387513132024756289,
|
||||
4654329375432538231, -292704475491394206, -3848998599978456535, 7623042350483453954,
|
||||
7725442901813263321, 9186225467561587250, -5132344747257272453, -6865740430362196008,
|
||||
2530936820058611833, 1636551876240043639, -3658707362519810009, 1452244145334316253,
|
||||
-7161729655835084979, -7943791770359481772, 9108481583171221009, -3200093350120725999,
|
||||
5007630032676973346, 2153168792952589781, 6720334534964750538, -3181825545719981703,
|
||||
3433922409283786309, 2285479922797300912, 3110614940896576130, -2856812446131932915,
|
||||
-3804580617188639299, 7163298419643543757, 4891138053923696990, 580618510277907015,
|
||||
1684034065251686769, 4429514767357295841, -8893025458299325803, -8103734041042601133,
|
||||
7177515271653460134, 4589042248470800257, -1530083407795771245, 143607045258444228,
|
||||
246994305896273627, -8356954712051676521, 6473547110565816071, 3092379936208876896,
|
||||
2058427839513754051, -4089587328327907870, 8785882556301281247, -3074039370013608197,
|
||||
-637529855400303673, 6137678347805511274, -7152924852417805802, 5708223427705576541,
|
||||
-3223714144396531304, 4358391411789012426, 325123008708389849, 6837621693887290924,
|
||||
4843721905315627004, -3212720814705499393, -3825019837890901156, 4602025990114250980,
|
||||
1044646352569048800, 9106614159853161675, -8394115921626182539, -4304087667751778808,
|
||||
2681532557646850893, 3681559472488511871, -3915372517896561773, -2889241648411946534,
|
||||
-6564663803938238204, -8060058171802589521, 581945337509520675, 3648778920718647903,
|
||||
-4799698790548231394, -7602572252857820065, 220828013409515943, -1072987336855386047,
|
||||
4287360518296753003, -4633371852008891965, 5513660857261085186, -2258542936462001533,
|
||||
-8744380348503999773, 8746140185685648781, 228500091334420247, 1356187007457302238,
|
||||
3019253992034194581, 3152601605678500003, -8793219284148773595, 5559581553696971176,
|
||||
4916432985369275664, -8559797105120221417, -5802598197927043732, 2868348622579915573,
|
||||
-7224052902810357288, -5894682518218493085, 2587672709781371173, -7706116723325376475,
|
||||
3092343956317362483, -5561119517847711700, 972445599196498113, -1558506600978816441,
|
||||
1708913533482282562, -2305554874185907314, -6005743014309462908, -6653329009633068701,
|
||||
-483583197311151195, 2488075924621352812, -4529369641467339140, -4663743555056261452,
|
||||
2997203966153298104, 1282559373026354493, 240113143146674385, 8665713329246516443,
|
||||
628141331766346752, -4651421219668005332, -7750560848702540400, 7596648026010355826,
|
||||
-3132152619100351065, 7834161864828164065, 7103445518877254909, 4390861237357459201,
|
||||
-4780718172614204074, -319889632007444440, 622261699494173647, -3186110786557562560,
|
||||
-8718967088789066690, -1948156510637662747, -8212195255998774408, -7028621931231314745,
|
||||
2623071828615234808, -4066058308780939700, -5484966924888173764, -6683604512778046238,
|
||||
-6756087640505506466, 5256026990536851868, 7841086888628396109, 6640857538655893162,
|
||||
-8021284697816458310, -7109857044414059830, -1689021141511844405, -4298087301956291063,
|
||||
-4077748265377282003, -998231156719803476, 2719520354384050532, 9132346697815513771,
|
||||
4332154495710163773, -2085582442760428892, 6994721091344268833, -2556143461985726874,
|
||||
-8567931991128098309, 59934747298466858, -3098398008776739403, -265597256199410390,
|
||||
2332206071942466437, -7522315324568406181, 3154897383618636503, -7585605855467168281,
|
||||
-6762850759087199275, 197309393502684135, -8579694182469508493, 2543179307861934850,
|
||||
4350769010207485119, -4468719947444108136, -7207776534213261296, -1224312577878317200,
|
||||
4287946071480840813, 8362686366770308971, 6486469209321732151, -5605644191012979782,
|
||||
-1669018511020473564, 4450022655153542367, -7618176296641240059, -3896357471549267421,
|
||||
-4596796223304447488, -6531150016257070659, -8982326463137525940, -4125325062227681798,
|
||||
-1306489741394045544, -8338554946557245229, 5329160409530630596, 7790979528857726136,
|
||||
4955070238059373407, -4304834761432101506, -6215295852904371179, 3007769226071157901,
|
||||
-6753025801236972788, 8928702772696731736, 7856187920214445904, -4748497451462800923,
|
||||
7900176660600710914, -7082800908938549136, -6797926979589575837, -6737316883512927978,
|
||||
4186670094382025798, 1883939007446035042, -414705992779907823, 3734134241178479257,
|
||||
4065968871360089196, 6953124200385847784, -7917685222115876751, -7585632937840318161,
|
||||
-5567246375906782599, -5256612402221608788, 3106378204088556331, -2894472214076325998,
|
||||
4565385105440252958, 1979884289539493806, -6891578849933910383, 3783206694208922581,
|
||||
8464961209802336085, 2843963751609577687, 3030678195484896323, -4429654462759003204,
|
||||
4459239494808162889, 402587895800087237, 8057891408711167515, 4541888170938985079,
|
||||
1042662272908816815, -3666068979732206850, 2647678726283249984, 2144477441549833761,
|
||||
-3417019821499388721, -2105601033380872185, 5916597177708541638, -8760774321402454447,
|
||||
8833658097025758785, 5970273481425315300, 563813119381731307, -6455022486202078793,
|
||||
1598828206250873866, -4016978389451217698, -2988328551145513985, -6071154634840136312,
|
||||
8469693267274066490, 125672920241807416, -3912292412830714870, -2559617104544284221,
|
||||
-486523741806024092, -4735332261862713930, 5923302823487327109, -9082480245771672572,
|
||||
-1808429243461201518, 7990420780896957397, 4317817392807076702, 3625184369705367340,
|
||||
-6482649271566653105, -3480272027152017464, -3225473396345736649, -368878695502291645,
|
||||
-3981164001421868007, -8522033136963788610, 7609280429197514109, 3020985755112334161,
|
||||
-2572049329799262942, 2635195723621160615, 5144520864246028816, -8188285521126945980,
|
||||
1567242097116389047, 8172389260191636581, -2885551685425483535, -7060359469858316883,
|
||||
-6480181133964513127, -7317004403633452381, 6011544915663598137, 5932255307352610768,
|
||||
2241128460406315459, -8327867140638080220, 3094483003111372717, 4583857460292963101,
|
||||
9079887171656594975, -384082854924064405, -3460631649611717935, 4225072055348026230,
|
||||
-7385151438465742745, 3801620336801580414, -399845416774701952, -7446754431269675473,
|
||||
7899055018877642622, 5421679761463003041, 5521102963086275121, -4975092593295409910,
|
||||
8735487530905098534, -7462844945281082830, -2080886987197029914, -1000715163927557685,
|
||||
-4253840471931071485, -5828896094657903328, 6424174453260338141, 359248545074932887,
|
||||
-5949720754023045210, -2426265837057637212, 3030918217665093212, -9077771202237461772,
|
||||
-3186796180789149575, 740416251634527158, -2142944401404840226, 6951781370868335478,
|
||||
399922722363687927, -8928469722407522623, -1378421100515597285, -8343051178220066766,
|
||||
-3030716356046100229, -8811767350470065420, 9026808440365124461, 6440783557497587732,
|
||||
4615674634722404292, 539897290441580544, 2096238225866883852, 8751955639408182687,
|
||||
-7316147128802486205, 7381039757301768559, 6157238513393239656, -1473377804940618233,
|
||||
8629571604380892756, 5280433031239081479, 7101611890139813254, 2479018537985767835,
|
||||
7169176924412769570, -1281305539061572506, -7865612307799218120, 2278447439451174845,
|
||||
3625338785743880657, 6477479539006708521, 8976185375579272206, -3712000482142939688,
|
||||
1326024180520890843, 7537449876596048829, 5464680203499696154, 3189671183162196045,
|
||||
6346751753565857109, -8982212049534145501, -6127578587196093755, -245039190118465649,
|
||||
-6320577374581628592, 7208698530190629697, 7276901792339343736, -7490986807540332668,
|
||||
4133292154170828382, 2918308698224194548, -7703910638917631350, -3929437324238184044,
|
||||
-4300543082831323144, -6344160503358350167, 5896236396443472108, -758328221503023383,
|
||||
-1894351639983151068, -307900319840287220, -6278469401177312761, -2171292963361310674,
|
||||
8382142935188824023, 9103922860780351547, 4152330101494654406,
|
||||
}
|
||||
)
|
||||
|
||||
type rngSource struct {
|
||||
tap int // index into vec
|
||||
feed int // index into vec
|
||||
vec [rngLen]int64 // current feedback register
|
||||
}
|
||||
|
||||
// seed rng x[n+1] = 48271 * x[n] mod (2**31 - 1)
|
||||
func seedrand(x int32) int32 {
|
||||
const (
|
||||
A = 48271
|
||||
Q = 44488
|
||||
R = 3399
|
||||
)
|
||||
|
||||
hi := x / Q
|
||||
lo := x % Q
|
||||
x = A*lo - R*hi
|
||||
if x < 0 {
|
||||
x += int32max
|
||||
}
|
||||
return x
|
||||
}
|
||||
|
||||
// Seed uses the provided seed value to initialize the generator to a deterministic state.
|
||||
func (rng *rngSource) Seed(seed int64) {
|
||||
rng.tap = 0
|
||||
rng.feed = rngLen - rngTap
|
||||
|
||||
seed = seed % int32max
|
||||
if seed < 0 {
|
||||
seed += int32max
|
||||
}
|
||||
if seed == 0 {
|
||||
seed = 89482311
|
||||
}
|
||||
|
||||
x := int32(seed)
|
||||
for i := -20; i < rngLen; i++ {
|
||||
x = seedrand(x)
|
||||
if i >= 0 {
|
||||
var u int64
|
||||
u = int64(x) << 40
|
||||
x = seedrand(x)
|
||||
u ^= int64(x) << 20
|
||||
x = seedrand(x)
|
||||
u ^= int64(x)
|
||||
u ^= rngCooked[i]
|
||||
rng.vec[i] = u
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Int64 returns a non-negative pseudo-random 63-bit integer as an int64.
|
||||
func (rng *rngSource) Int64() int64 {
|
||||
return int64(rng.Uint64() & rngMask)
|
||||
}
|
||||
|
||||
// Uint64 returns a non-negative pseudo-random 64-bit integer as a uint64.
|
||||
func (rng *rngSource) Uint64() uint64 {
|
||||
rng.tap--
|
||||
if rng.tap < 0 {
|
||||
rng.tap += rngLen
|
||||
}
|
||||
|
||||
rng.feed--
|
||||
if rng.feed < 0 {
|
||||
rng.feed += rngLen
|
||||
}
|
||||
|
||||
x := rng.vec[rng.feed] + rng.vec[rng.tap]
|
||||
rng.vec[rng.feed] = x
|
||||
return uint64(x)
|
||||
}
|
Loading…
Reference in New Issue
Block a user