Deprecated: Creation of dynamic property NewFoldLabs\WP\Module\MyProducts\ProductsApi::$namespace is deprecated in /home3/enderthr/public_html/wp-content/plugins/bluehost-wordpress-plugin/vendor/newfold-labs/wp-module-my-products/includes/ProductsApi.php on line 41

Deprecated: Creation of dynamic property NewFoldLabs\WP\Module\MyProducts\ProductsApi::$rest_base is deprecated in /home3/enderthr/public_html/wp-content/plugins/bluehost-wordpress-plugin/vendor/newfold-labs/wp-module-my-products/includes/ProductsApi.php on line 42

Warning: Cannot modify header information - headers already sent by (output started at /home3/enderthr/public_html/wp-content/plugins/bluehost-wordpress-plugin/vendor/newfold-labs/wp-module-my-products/includes/ProductsApi.php:41) in /home3/enderthr/public_html/wp-includes/rest-api/class-wp-rest-server.php on line 1831

Warning: Cannot modify header information - headers already sent by (output started at /home3/enderthr/public_html/wp-content/plugins/bluehost-wordpress-plugin/vendor/newfold-labs/wp-module-my-products/includes/ProductsApi.php:41) in /home3/enderthr/public_html/wp-includes/rest-api/class-wp-rest-server.php on line 1831

Warning: Cannot modify header information - headers already sent by (output started at /home3/enderthr/public_html/wp-content/plugins/bluehost-wordpress-plugin/vendor/newfold-labs/wp-module-my-products/includes/ProductsApi.php:41) in /home3/enderthr/public_html/wp-includes/rest-api/class-wp-rest-server.php on line 1831

Warning: Cannot modify header information - headers already sent by (output started at /home3/enderthr/public_html/wp-content/plugins/bluehost-wordpress-plugin/vendor/newfold-labs/wp-module-my-products/includes/ProductsApi.php:41) in /home3/enderthr/public_html/wp-includes/rest-api/class-wp-rest-server.php on line 1831

Warning: Cannot modify header information - headers already sent by (output started at /home3/enderthr/public_html/wp-content/plugins/bluehost-wordpress-plugin/vendor/newfold-labs/wp-module-my-products/includes/ProductsApi.php:41) in /home3/enderthr/public_html/wp-includes/rest-api/class-wp-rest-server.php on line 1831

Warning: Cannot modify header information - headers already sent by (output started at /home3/enderthr/public_html/wp-content/plugins/bluehost-wordpress-plugin/vendor/newfold-labs/wp-module-my-products/includes/ProductsApi.php:41) in /home3/enderthr/public_html/wp-includes/rest-api/class-wp-rest-server.php on line 1831

Warning: Cannot modify header information - headers already sent by (output started at /home3/enderthr/public_html/wp-content/plugins/bluehost-wordpress-plugin/vendor/newfold-labs/wp-module-my-products/includes/ProductsApi.php:41) in /home3/enderthr/public_html/wp-includes/rest-api/class-wp-rest-server.php on line 1831

Warning: Cannot modify header information - headers already sent by (output started at /home3/enderthr/public_html/wp-content/plugins/bluehost-wordpress-plugin/vendor/newfold-labs/wp-module-my-products/includes/ProductsApi.php:41) in /home3/enderthr/public_html/wp-includes/rest-api/class-wp-rest-server.php on line 1831
{"id":111,"date":"2023-03-14T03:37:52","date_gmt":"2023-03-14T03:37:52","guid":{"rendered":"https:\/\/ender314.com\/?p=111"},"modified":"2023-03-14T03:37:58","modified_gmt":"2023-03-14T03:37:58","slug":"an-interesting-prng-with-an-add-rotate-and-subtract","status":"publish","type":"post","link":"https:\/\/ender314.com\/?p=111","title":{"rendered":"An Interesting PRNG with an Add, Rotate, and Subtract<\/strong>"},"content":{"rendered":"\n

I frequently run my genetic programming software with different parameters, seeing what it will find. When asked to find a pseudo-random number generator under some given constraints, it is fairly good at finding a solution. The solution it finds is typically chaotic, though, with an unverifiable period. That\u2019s not very useful practically, as the chaotic nature means that some seeds may have very short times before they start repeating. Take, for example, the generator below, produced by a short simulation:<\/p>\n\n\n\n

RMU S2,51,954523823516132654;\nXSR S2,13;\nXOR OP,S2;<\/code><\/pre>\n\n\n\n

Translated into C# (where there is a class-level \u201cstate\u201d variable), this is<\/p>\n\n\n\n

public ulong NextRandom()\n{\n    state = BitOperations.RotateLeft(state, 51);\n    state = state * 954523823516132654;\n    state = state ^ (state >> 13);\n    return state;\n}<\/code><\/pre>\n\n\n\n

Recall that ^ is the XOR operator in C#. People keep asking me if that\u2019s a \u201craise to a power\u201d operator.<\/p>\n\n\n\n

This generator passes some randomness tests at a million numbers generated, and can probably be tuned to pass some fairly strong tests if some of the parameters are changed. Unfortunately, it mutates the state in a fairly chaotic way, and I\u2019m unaware of a way to determine what the shortest possible period is. There might be some seed value of state for which it repeats after 16 values, or a billion. Without guarantees about period, it\u2019s impractical to use.<\/p>\n\n\n\n

However, recently I ran the genetic simulation with a constraint of not using multiplication, and it found the solution below.<\/p>\n\n\n\n

ADD S2,S1;\r\nROR S2,1;\r\nSUB S1,12076313562642528635;\r\nXOR OP,S2;<\/code><\/pre>\n\n\n\n

Translated into C# (this time with two class-level state variables), this is<\/p>\n\n\n\n

public ulong NextRandom()\n{\n    state2 = state2 + state1;\n    state2 = BitOperations.RotateRight(state2, 1);\n    state1 = state1 - 12076313562642528635;\n    return state2;\n}<\/code><\/pre>\n\n\n\n

This generator is interesting because state1 changes from iteration to iteration by subtracting an odd number, and thus state1 will go through every possible ulong before repeating. I have no idea what the actual period of state2, and thus the whole generator is, but it is atleast the period of state1, which is 2^64. This is interesting because it is a rare case where I can prove a lower bound on the period by inspection, and the generator actually passes some decent tests of randomness. The generator is also remarkably simple, using only a single add, subtract, and rotate, so it should be competitive speedwise with some of the existing cutting edge PRNG\u2019s.<\/p>\n\n\n\n

I have tested this generator on a given seed to 100 billion numbers, using the GCD test, the gorilla test with word lengths 7 and 17, and the linear serial correllation test, and it passed all of the tests. I think the rotate constant it found was actually 4, not 1. I tested it at 1 in an attempt to see if that weakened it, but it apparently is quite strong at those parameters. I haven\u2019t yet tuned any of the parameters, but it is remarkably simple. State1 is what Marsaglia called a Weyl sequence. Not very random. State2 is an accumulator that gets rotated between accumulations. Apparently that\u2019s a fairly decent way to randomize things.<\/p>\n","protected":false},"excerpt":{"rendered":"

I frequently run my genetic programming software with different parameters, seeing what it will find. When asked to find a pseudo-random number generator under some given constraints, it is fairly good at finding a solution. The solution it finds is typically chaotic, though, with an unverifiable period. That\u2019s not very useful practically, as the chaotic […]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"nf_dc_page":"","om_disable_all_campaigns":false,"WB4WB4WP_MODE":"","WB4WP_PAGE_SCRIPTS":"","WB4WP_PAGE_STYLES":"","WB4WP_PAGE_FONTS":"","WB4WP_PAGE_HEADER":"","WB4WP_PAGE_FOOTER":"","_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-111","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"yoast_head":"\nAn Interesting PRNG with an Add, Rotate, and Subtract - Ender314's Random Number Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/ender314.com\/?p=111\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"An Interesting PRNG with an Add, Rotate, and Subtract - Ender314's Random Number Blog\" \/>\n<meta property=\"og:description\" content=\"I frequently run my genetic programming software with different parameters, seeing what it will find. When asked to find a pseudo-random number generator under some given constraints, it is fairly good at finding a solution. The solution it finds is typically chaotic, though, with an unverifiable period. That\u2019s not very useful practically, as the chaotic […]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/ender314.com\/?p=111\" \/>\n<meta property=\"og:site_name\" content=\"Ender314's Random Number Blog\" \/>\n<meta property=\"article:published_time\" content=\"2023-03-14T03:37:52+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-03-14T03:37:58+00:00\" \/>\n<meta name=\"author\" content=\"Ender314\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Ender314\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/ender314.com\/?p=111\",\"url\":\"https:\/\/ender314.com\/?p=111\",\"name\":\"An Interesting PRNG with an Add, Rotate, and Subtract - Ender314's Random Number Blog\",\"isPartOf\":{\"@id\":\"https:\/\/ender314.com\/#website\"},\"datePublished\":\"2023-03-14T03:37:52+00:00\",\"dateModified\":\"2023-03-14T03:37:58+00:00\",\"author\":{\"@id\":\"https:\/\/ender314.com\/#\/schema\/person\/a9a77c40aeab4681ad07b8f92765cc8f\"},\"breadcrumb\":{\"@id\":\"https:\/\/ender314.com\/?p=111#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/ender314.com\/?p=111\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/ender314.com\/?p=111#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/ender314.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"An Interesting PRNG with an Add, Rotate, and Subtract\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/ender314.com\/#website\",\"url\":\"https:\/\/ender314.com\/\",\"name\":\"Ender314's Random Number Blog\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/ender314.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/ender314.com\/#\/schema\/person\/a9a77c40aeab4681ad07b8f92765cc8f\",\"name\":\"Ender314\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/ender314.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/eaf7d249d72a7ef23f2b690d8def661a?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/eaf7d249d72a7ef23f2b690d8def661a?s=96&d=mm&r=g\",\"caption\":\"Ender314\"},\"url\":\"https:\/\/ender314.com\/?author=1\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"An Interesting PRNG with an Add, Rotate, and Subtract - Ender314's Random Number Blog","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/ender314.com\/?p=111","og_locale":"en_US","og_type":"article","og_title":"An Interesting PRNG with an Add, Rotate, and Subtract - Ender314's Random Number Blog","og_description":"I frequently run my genetic programming software with different parameters, seeing what it will find. When asked to find a pseudo-random number generator under some given constraints, it is fairly good at finding a solution. The solution it finds is typically chaotic, though, with an unverifiable period. That\u2019s not very useful practically, as the chaotic […]","og_url":"https:\/\/ender314.com\/?p=111","og_site_name":"Ender314's Random Number Blog","article_published_time":"2023-03-14T03:37:52+00:00","article_modified_time":"2023-03-14T03:37:58+00:00","author":"Ender314","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Ender314","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/ender314.com\/?p=111","url":"https:\/\/ender314.com\/?p=111","name":"An Interesting PRNG with an Add, Rotate, and Subtract - Ender314's Random Number Blog","isPartOf":{"@id":"https:\/\/ender314.com\/#website"},"datePublished":"2023-03-14T03:37:52+00:00","dateModified":"2023-03-14T03:37:58+00:00","author":{"@id":"https:\/\/ender314.com\/#\/schema\/person\/a9a77c40aeab4681ad07b8f92765cc8f"},"breadcrumb":{"@id":"https:\/\/ender314.com\/?p=111#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/ender314.com\/?p=111"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/ender314.com\/?p=111#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/ender314.com\/"},{"@type":"ListItem","position":2,"name":"An Interesting PRNG with an Add, Rotate, and Subtract"}]},{"@type":"WebSite","@id":"https:\/\/ender314.com\/#website","url":"https:\/\/ender314.com\/","name":"Ender314's Random Number Blog","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/ender314.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/ender314.com\/#\/schema\/person\/a9a77c40aeab4681ad07b8f92765cc8f","name":"Ender314","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/ender314.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/eaf7d249d72a7ef23f2b690d8def661a?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/eaf7d249d72a7ef23f2b690d8def661a?s=96&d=mm&r=g","caption":"Ender314"},"url":"https:\/\/ender314.com\/?author=1"}]}},"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/ender314.com\/index.php?rest_route=\/wp\/v2\/posts\/111"}],"collection":[{"href":"https:\/\/ender314.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ender314.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ender314.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ender314.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=111"}],"version-history":[{"count":2,"href":"https:\/\/ender314.com\/index.php?rest_route=\/wp\/v2\/posts\/111\/revisions"}],"predecessor-version":[{"id":113,"href":"https:\/\/ender314.com\/index.php?rest_route=\/wp\/v2\/posts\/111\/revisions\/113"}],"wp:attachment":[{"href":"https:\/\/ender314.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=111"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ender314.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=111"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ender314.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=111"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}