squiggle.c/references/Xorshift
2023-12-03 18:46:24 +00:00

1045 lines
131 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html>
<html class="client-nojs vector-feature-language-in-header-enabled vector-feature-language-in-main-page-header-disabled vector-feature-sticky-header-disabled vector-feature-page-tools-pinned-disabled vector-feature-toc-pinned-clientpref-1 vector-feature-main-menu-pinned-disabled vector-feature-limited-width-clientpref-1 vector-feature-limited-width-content-enabled vector-feature-zebra-design-disabled vector-feature-custom-font-size-clientpref-0 vector-feature-client-preferences-disabled vector-feature-typography-survey-disabled vector-toc-available" lang="en" dir="ltr">
<head>
<meta charset="UTF-8">
<title>Xorshift - Wikipedia</title>
<script>(function(){var className="client-js vector-feature-language-in-header-enabled vector-feature-language-in-main-page-header-disabled vector-feature-sticky-header-disabled vector-feature-page-tools-pinned-disabled vector-feature-toc-pinned-clientpref-1 vector-feature-main-menu-pinned-disabled vector-feature-limited-width-clientpref-1 vector-feature-limited-width-content-enabled vector-feature-zebra-design-disabled vector-feature-custom-font-size-clientpref-0 vector-feature-client-preferences-disabled vector-feature-typography-survey-disabled vector-toc-available";var cookie=document.cookie.match(/(?:^|; )enwikimwclientpreferences=([^;]+)/);if(cookie){cookie[1].split('%2C').forEach(function(pref){className=className.replace(new RegExp('(^| )'+pref.replace(/-clientpref-\w+$|[^\w-]+/g,'')+'-clientpref-\\w+( |$)'),'$1'+pref+'$2');});}document.documentElement.className=className;}());RLCONF={"wgBreakFrames":false,"wgSeparatorTransformTable":["",""],"wgDigitTransformTable":["",""],
"wgDefaultDateFormat":"dmy","wgMonthNames":["","January","February","March","April","May","June","July","August","September","October","November","December"],"wgRequestId":"5fc1186c-12f1-4e7d-b82c-9c11f248c914","wgCanonicalNamespace":"","wgCanonicalSpecialPageName":false,"wgNamespaceNumber":0,"wgPageName":"Xorshift","wgTitle":"Xorshift","wgCurRevisionId":1177332258,"wgRevisionId":1177332258,"wgArticleId":17099722,"wgIsArticle":true,"wgIsRedirect":false,"wgAction":"view","wgUserName":null,"wgUserGroups":["*"],"wgCategories":["Articles with short description","Short description is different from Wikidata","Articles with example C code","Pseudorandom number generators"],"wgPageViewLanguage":"en","wgPageContentLanguage":"en","wgPageContentModel":"wikitext","wgRelevantPageName":"Xorshift","wgRelevantArticleId":17099722,"wgIsProbablyEditable":true,"wgRelevantPageIsProbablyEditable":true,"wgRestrictionEdit":[],"wgRestrictionMove":[],"wgNoticeProject":"wikipedia","wgFlaggedRevsParams":{"tags":
{"status":{"levels":1}}},"wgMediaViewerOnClick":true,"wgMediaViewerEnabledByDefault":true,"wgPopupsFlags":6,"wgVisualEditor":{"pageLanguageCode":"en","pageLanguageDir":"ltr","pageVariantFallbacks":"en"},"wgMFDisplayWikibaseDescriptions":{"search":true,"watchlist":true,"tagline":false,"nearby":true},"wgWMESchemaEditAttemptStepOversample":false,"wgWMEPageLength":20000,"wgULSCurrentAutonym":"English","wgCentralAuthMobileDomain":false,"wgEditSubmitButtonLabelPublish":true,"wgULSPosition":"interlanguage","wgULSisCompactLinksEnabled":true,"wgULSisLanguageSelectorEmpty":false,"wgWikibaseItemId":"Q2576999","wgCheckUserClientHintsHeadersJsApi":["architecture","bitness","brands","fullVersionList","mobile","model","platform","platformVersion"],"GEHomepageSuggestedEditsEnableTopics":true,"wgGETopicsMatchModeEnabled":false,"wgGEStructuredTaskRejectionReasonTextInputEnabled":false,"wgGELevelingUpEnabledForUser":false};RLSTATE={"skins.vector.user.styles":"ready","ext.globalCssJs.user.styles":"ready",
"site.styles":"ready","user.styles":"ready","skins.vector.user":"ready","ext.globalCssJs.user":"ready","user":"ready","user.options":"loading","ext.cite.styles":"ready","ext.pygments":"ready","codex-search-styles":"ready","skins.vector.styles":"ready","skins.vector.icons":"ready","ext.visualEditor.desktopArticleTarget.noscript":"ready","ext.uls.interlanguage":"ready","wikibase.client.init":"ready","ext.wikimediaBadges":"ready"};RLPAGEMODULES=["ext.cite.ux-enhancements","mediawiki.page.media","site","mediawiki.page.ready","mediawiki.toc","skins.vector.js","ext.centralNotice.geoIP","ext.centralNotice.startUp","ext.gadget.ReferenceTooltips","ext.gadget.switcher","ext.urlShortener.toolbar","ext.centralauth.centralautologin","mmv.head","mmv.bootstrap.autostart","ext.popups","ext.visualEditor.desktopArticleTarget.init","ext.visualEditor.targetLoader","ext.echo.centralauth","ext.eventLogging","ext.wikimediaEvents","ext.navigationTiming","ext.uls.compactlinks","ext.uls.interface",
"ext.cx.eventlogging.campaigns","ext.cx.uls.quick.actions","wikibase.client.vector-2022","ext.checkUser.clientHints","ext.growthExperiments.SuggestedEditSession"];</script>
<script>(RLQ=window.RLQ||[]).push(function(){mw.loader.impl(function(){return["user.options@12s5i",function($,jQuery,require,module){mw.user.tokens.set({"patrolToken":"+\\","watchToken":"+\\","csrfToken":"+\\"});
}];});});</script>
<link rel="stylesheet" href="/w/load.php?lang=en&amp;modules=codex-search-styles%7Cext.cite.styles%7Cext.pygments%2CwikimediaBadges%7Cext.uls.interlanguage%7Cext.visualEditor.desktopArticleTarget.noscript%7Cskins.vector.icons%2Cstyles%7Cwikibase.client.init&amp;only=styles&amp;skin=vector-2022">
<script async="" src="/w/load.php?lang=en&amp;modules=startup&amp;only=scripts&amp;raw=1&amp;skin=vector-2022"></script>
<meta name="ResourceLoaderDynamicStyles" content="">
<link rel="stylesheet" href="/w/load.php?lang=en&amp;modules=site.styles&amp;only=styles&amp;skin=vector-2022">
<meta name="generator" content="MediaWiki 1.42.0-wmf.5">
<meta name="referrer" content="origin">
<meta name="referrer" content="origin-when-cross-origin">
<meta name="robots" content="max-image-preview:standard">
<meta name="format-detection" content="telephone=no">
<meta property="og:image" content="https://upload.wikimedia.org/wikipedia/commons/e/ee/Xorshift.png">
<meta property="og:image:width" content="1200">
<meta property="og:image:height" content="1200">
<meta property="og:image" content="https://upload.wikimedia.org/wikipedia/commons/thumb/e/ee/Xorshift.png/800px-Xorshift.png">
<meta property="og:image:width" content="800">
<meta property="og:image:height" content="800">
<meta property="og:image" content="https://upload.wikimedia.org/wikipedia/commons/thumb/e/ee/Xorshift.png/640px-Xorshift.png">
<meta property="og:image:width" content="640">
<meta property="og:image:height" content="640">
<meta name="viewport" content="width=1000">
<meta property="og:title" content="Xorshift - Wikipedia">
<meta property="og:type" content="website">
<link rel="preconnect" href="//upload.wikimedia.org">
<link rel="alternate" media="only screen and (max-width: 720px)" href="//en.m.wikipedia.org/wiki/Xorshift">
<link rel="alternate" type="application/x-wiki" title="Edit this page" href="/w/index.php?title=Xorshift&amp;action=edit">
<link rel="apple-touch-icon" href="/static/apple-touch/wikipedia.png">
<link rel="icon" href="/static/favicon/wikipedia.ico">
<link rel="search" type="application/opensearchdescription+xml" href="/w/opensearch_desc.php" title="Wikipedia (en)">
<link rel="EditURI" type="application/rsd+xml" href="//en.wikipedia.org/w/api.php?action=rsd">
<link rel="canonical" href="https://en.wikipedia.org/wiki/Xorshift">
<link rel="license" href="https://creativecommons.org/licenses/by-sa/4.0/deed.en">
<link rel="alternate" type="application/atom+xml" title="Wikipedia Atom feed" href="/w/index.php?title=Special:RecentChanges&amp;feed=atom">
<link rel="dns-prefetch" href="//meta.wikimedia.org" />
<link rel="dns-prefetch" href="//login.wikimedia.org">
</head>
<body class="skin-vector skin-vector-search-vue mediawiki ltr sitedir-ltr mw-hide-empty-elt ns-0 ns-subject mw-editable page-Xorshift rootpage-Xorshift skin-vector-2022 action-view"><a class="mw-jump-link" href="#bodyContent">Jump to content</a>
<div class="vector-header-container">
<header class="vector-header mw-header">
<div class="vector-header-start">
<nav class="vector-main-menu-landmark" aria-label="Site" role="navigation">
<div id="vector-main-menu-dropdown" class="vector-dropdown vector-main-menu-dropdown vector-button-flush-left vector-button-flush-right" >
<input type="checkbox" id="vector-main-menu-dropdown-checkbox" role="button" aria-haspopup="true" data-event-name="ui.dropdown-vector-main-menu-dropdown" class="vector-dropdown-checkbox " aria-label="Main menu" >
<label id="vector-main-menu-dropdown-label" for="vector-main-menu-dropdown-checkbox" class="vector-dropdown-label cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet cdx-button--icon-only " aria-hidden="true" ><span class="vector-icon mw-ui-icon-menu mw-ui-icon-wikimedia-menu"></span>
<span class="vector-dropdown-label-text">Main menu</span>
</label>
<div class="vector-dropdown-content">
<div id="vector-main-menu-unpinned-container" class="vector-unpinned-container">
<div id="vector-main-menu" class="vector-main-menu vector-pinnable-element">
<div
class="vector-pinnable-header vector-main-menu-pinnable-header vector-pinnable-header-unpinned"
data-feature-name="main-menu-pinned"
data-pinnable-element-id="vector-main-menu"
data-pinned-container-id="vector-main-menu-pinned-container"
data-unpinned-container-id="vector-main-menu-unpinned-container"
>
<div class="vector-pinnable-header-label">Main menu</div>
<button class="vector-pinnable-header-toggle-button vector-pinnable-header-pin-button" data-event-name="pinnable-header.vector-main-menu.pin">move to sidebar</button>
<button class="vector-pinnable-header-toggle-button vector-pinnable-header-unpin-button" data-event-name="pinnable-header.vector-main-menu.unpin">hide</button>
</div>
<div id="p-navigation" class="vector-menu mw-portlet mw-portlet-navigation" >
<div class="vector-menu-heading">
Navigation
</div>
<div class="vector-menu-content">
<ul class="vector-menu-content-list">
<li id="n-mainpage-description" class="mw-list-item"><a href="/wiki/Main_Page" title="Visit the main page [z]" accesskey="z"><span>Main page</span></a></li><li id="n-contents" class="mw-list-item"><a href="/wiki/Wikipedia:Contents" title="Guides to browsing Wikipedia"><span>Contents</span></a></li><li id="n-currentevents" class="mw-list-item"><a href="/wiki/Portal:Current_events" title="Articles related to current events"><span>Current events</span></a></li><li id="n-randompage" class="mw-list-item"><a href="/wiki/Special:Random" title="Visit a randomly selected article [x]" accesskey="x"><span>Random article</span></a></li><li id="n-aboutsite" class="mw-list-item"><a href="/wiki/Wikipedia:About" title="Learn about Wikipedia and how it works"><span>About Wikipedia</span></a></li><li id="n-contactpage" class="mw-list-item"><a href="//en.wikipedia.org/wiki/Wikipedia:Contact_us" title="How to contact Wikipedia"><span>Contact us</span></a></li><li id="n-sitesupport" class="mw-list-item"><a href="https://donate.wikimedia.org/wiki/Special:FundraiserRedirector?utm_source=donate&amp;utm_medium=sidebar&amp;utm_campaign=C13_en.wikipedia.org&amp;uselang=en" title="Support us by donating to the Wikimedia Foundation"><span>Donate</span></a></li>
</ul>
</div>
</div>
<div id="p-interaction" class="vector-menu mw-portlet mw-portlet-interaction" >
<div class="vector-menu-heading">
Contribute
</div>
<div class="vector-menu-content">
<ul class="vector-menu-content-list">
<li id="n-help" class="mw-list-item"><a href="/wiki/Help:Contents" title="Guidance on how to use and edit Wikipedia"><span>Help</span></a></li><li id="n-introduction" class="mw-list-item"><a href="/wiki/Help:Introduction" title="Learn how to edit Wikipedia"><span>Learn to edit</span></a></li><li id="n-portal" class="mw-list-item"><a href="/wiki/Wikipedia:Community_portal" title="The hub for editors"><span>Community portal</span></a></li><li id="n-recentchanges" class="mw-list-item"><a href="/wiki/Special:RecentChanges" title="A list of recent changes to Wikipedia [r]" accesskey="r"><span>Recent changes</span></a></li><li id="n-upload" class="mw-list-item"><a href="/wiki/Wikipedia:File_upload_wizard" title="Add images or other media for use on Wikipedia"><span>Upload file</span></a></li>
</ul>
</div>
</div>
<div class="vector-main-menu-action vector-main-menu-action-lang-alert">
<div class="vector-main-menu-action-item">
<div class="vector-main-menu-action-heading vector-menu-heading">Languages</div>
<div class="vector-main-menu-action-content vector-menu-content">
<div class="mw-message-box cdx-message cdx-message--block mw-message-box-notice cdx-message--notice vector-language-sidebar-alert"><span class="cdx-message__icon"></span><div class="cdx-message__content">Language links are at the top of the page across from the title.</div></div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</nav>
<a href="/wiki/Main_Page" class="mw-logo">
<img class="mw-logo-icon" src="/static/images/icons/wikipedia.png" alt="" aria-hidden="true" height="50" width="50">
<span class="mw-logo-container">
<img class="mw-logo-wordmark" alt="Wikipedia" src="/static/images/mobile/copyright/wikipedia-wordmark-en.svg" style="width: 7.5em; height: 1.125em;">
<img class="mw-logo-tagline" alt="The Free Encyclopedia" src="/static/images/mobile/copyright/wikipedia-tagline-en.svg" width="117" height="13" style="width: 7.3125em; height: 0.8125em;">
</span>
</a>
</div>
<div class="vector-header-end">
<div id="p-search" role="search" class="vector-search-box-vue vector-search-box-collapses vector-search-box-show-thumbnail vector-search-box-auto-expand-width vector-search-box">
<a href="/wiki/Special:Search" class="cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet cdx-button--icon-only search-toggle" id="" title="Search Wikipedia [f]" accesskey="f"><span class="vector-icon mw-ui-icon-search mw-ui-icon-wikimedia-search"></span>
<span>Search</span>
</a>
<div class="vector-typeahead-search-container">
<div class="cdx-typeahead-search cdx-typeahead-search--show-thumbnail cdx-typeahead-search--auto-expand-width">
<form action="/w/index.php" id="searchform" class="cdx-search-input cdx-search-input--has-end-button">
<div id="simpleSearch" class="cdx-search-input__input-wrapper" data-search-loc="header-moved">
<div class="cdx-text-input cdx-text-input--has-start-icon">
<input
class="cdx-text-input__input"
type="search" name="search" placeholder="Search Wikipedia" aria-label="Search Wikipedia" autocapitalize="sentences" title="Search Wikipedia [f]" accesskey="f" id="searchInput"
>
<span class="cdx-text-input__icon cdx-text-input__start-icon"></span>
</div>
<input type="hidden" name="title" value="Special:Search">
</div>
<button class="cdx-button cdx-search-input__end-button">Search</button>
</form>
</div>
</div>
</div>
<nav class="vector-user-links vector-user-links-wide" aria-label="Personal tools" role="navigation" >
<div class="vector-user-links-main">
<div id="p-vector-user-menu-preferences" class="vector-menu mw-portlet emptyPortlet" >
<div class="vector-menu-content">
<ul class="vector-menu-content-list">
</ul>
</div>
</div>
<div id="p-vector-user-menu-userpage" class="vector-menu mw-portlet emptyPortlet" >
<div class="vector-menu-content">
<ul class="vector-menu-content-list">
</ul>
</div>
</div>
<div id="p-vector-user-menu-notifications" class="vector-menu mw-portlet emptyPortlet" >
<div class="vector-menu-content">
<ul class="vector-menu-content-list">
</ul>
</div>
</div>
<div id="p-vector-user-menu-overflow" class="vector-menu mw-portlet" >
<div class="vector-menu-content">
<ul class="vector-menu-content-list">
<li id="pt-createaccount-2" class="user-links-collapsible-item mw-list-item user-links-collapsible-item"><a data-mw="interface" href="/w/index.php?title=Special:CreateAccount&amp;returnto=Xorshift" title="You are encouraged to create an account and log in; however, it is not mandatory" class=""><span>Create account</span></a>
</li>
<li id="pt-login-2" class="user-links-collapsible-item mw-list-item user-links-collapsible-item"><a data-mw="interface" href="/w/index.php?title=Special:UserLogin&amp;returnto=Xorshift" title="You&#039;re encouraged to log in; however, it&#039;s not mandatory. [o]" accesskey="o" class=""><span>Log in</span></a>
</li>
</ul>
</div>
</div>
</div>
<div id="vector-user-links-dropdown" class="vector-dropdown vector-user-menu vector-button-flush-right vector-user-menu-logged-out" title="Log in and more options" >
<input type="checkbox" id="vector-user-links-dropdown-checkbox" role="button" aria-haspopup="true" data-event-name="ui.dropdown-vector-user-links-dropdown" class="vector-dropdown-checkbox " aria-label="Personal tools" >
<label id="vector-user-links-dropdown-label" for="vector-user-links-dropdown-checkbox" class="vector-dropdown-label cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet cdx-button--icon-only " aria-hidden="true" ><span class="vector-icon mw-ui-icon-ellipsis mw-ui-icon-wikimedia-ellipsis"></span>
<span class="vector-dropdown-label-text">Personal tools</span>
</label>
<div class="vector-dropdown-content">
<div id="p-personal" class="vector-menu mw-portlet mw-portlet-personal user-links-collapsible-item" title="User menu" >
<div class="vector-menu-content">
<ul class="vector-menu-content-list">
<li id="pt-createaccount" class="user-links-collapsible-item mw-list-item"><a href="/w/index.php?title=Special:CreateAccount&amp;returnto=Xorshift" title="You are encouraged to create an account and log in; however, it is not mandatory"><span class="vector-icon mw-ui-icon-userAdd mw-ui-icon-wikimedia-userAdd"></span> <span>Create account</span></a></li><li id="pt-login" class="user-links-collapsible-item mw-list-item"><a href="/w/index.php?title=Special:UserLogin&amp;returnto=Xorshift" title="You&#039;re encouraged to log in; however, it&#039;s not mandatory. [o]" accesskey="o"><span class="vector-icon mw-ui-icon-logIn mw-ui-icon-wikimedia-logIn"></span> <span>Log in</span></a></li>
</ul>
</div>
</div>
<div id="p-user-menu-anon-editor" class="vector-menu mw-portlet mw-portlet-user-menu-anon-editor" >
<div class="vector-menu-heading">
Pages for logged out editors <a href="/wiki/Help:Introduction" aria-label="Learn more about editing"><span>learn more</span></a>
</div>
<div class="vector-menu-content">
<ul class="vector-menu-content-list">
<li id="pt-anoncontribs" class="mw-list-item"><a href="/wiki/Special:MyContributions" title="A list of edits made from this IP address [y]" accesskey="y"><span>Contributions</span></a></li><li id="pt-anontalk" class="mw-list-item"><a href="/wiki/Special:MyTalk" title="Discussion about edits from this IP address [n]" accesskey="n"><span>Talk</span></a></li>
</ul>
</div>
</div>
</div>
</div>
</nav>
</div>
</header>
</div>
<div class="mw-page-container">
<div class="mw-page-container-inner">
<div class="vector-sitenotice-container">
<div id="siteNotice"><!-- CentralNotice --></div>
</div>
<div class="vector-main-menu-container">
<div id="mw-navigation">
<nav id="mw-panel" class="vector-main-menu-landmark" aria-label="Site" role="navigation">
<div id="vector-main-menu-pinned-container" class="vector-pinned-container">
</div>
</nav>
</div>
</div>
<nav id="mw-panel-toc" role="navigation" aria-label="Contents" data-event-name="ui.sidebar-toc" class="mw-table-of-contents-container vector-toc-landmark vector-sticky-pinned-container">
<div id="vector-toc-pinned-container" class="vector-pinned-container">
<div id="vector-toc" class="vector-toc vector-pinnable-element">
<div
class="vector-pinnable-header vector-toc-pinnable-header vector-pinnable-header-pinned"
data-feature-name="toc-pinned"
data-pinnable-element-id="vector-toc"
>
<h2 class="vector-pinnable-header-label">Contents</h2>
<button class="vector-pinnable-header-toggle-button vector-pinnable-header-pin-button" data-event-name="pinnable-header.vector-toc.pin">move to sidebar</button>
<button class="vector-pinnable-header-toggle-button vector-pinnable-header-unpin-button" data-event-name="pinnable-header.vector-toc.unpin">hide</button>
</div>
<ul class="vector-toc-contents" id="mw-panel-toc-list">
<li id="toc-mw-content-text"
class="vector-toc-list-item vector-toc-level-1">
<a href="#" class="vector-toc-link">
<div class="vector-toc-text">(Top)</div>
</a>
</li>
<li id="toc-Example_implementation"
class="vector-toc-list-item vector-toc-level-1 vector-toc-list-item-expanded">
<a class="vector-toc-link" href="#Example_implementation">
<div class="vector-toc-text">
<span class="vector-toc-numb">1</span>Example implementation</div>
</a>
<ul id="toc-Example_implementation-sublist" class="vector-toc-list">
</ul>
</li>
<li id="toc-Non-linear_variations"
class="vector-toc-list-item vector-toc-level-1 vector-toc-list-item-expanded">
<a class="vector-toc-link" href="#Non-linear_variations">
<div class="vector-toc-text">
<span class="vector-toc-numb">2</span>Non-linear variations</div>
</a>
<button aria-controls="toc-Non-linear_variations-sublist" class="cdx-button cdx-button--weight-quiet cdx-button--icon-only vector-toc-toggle">
<span class="vector-icon vector-icon--x-small mw-ui-icon-wikimedia-expand"></span>
<span>Toggle Non-linear variations subsection</span>
</button>
<ul id="toc-Non-linear_variations-sublist" class="vector-toc-list">
<li id="toc-xorwow"
class="vector-toc-list-item vector-toc-level-2">
<a class="vector-toc-link" href="#xorwow">
<div class="vector-toc-text">
<span class="vector-toc-numb">2.1</span>xorwow</div>
</a>
<ul id="toc-xorwow-sublist" class="vector-toc-list">
</ul>
</li>
<li id="toc-xorshift*"
class="vector-toc-list-item vector-toc-level-2">
<a class="vector-toc-link" href="#xorshift*">
<div class="vector-toc-text">
<span class="vector-toc-numb">2.2</span>xorshift*</div>
</a>
<ul id="toc-xorshift*-sublist" class="vector-toc-list">
</ul>
</li>
<li id="toc-xorshift+"
class="vector-toc-list-item vector-toc-level-2">
<a class="vector-toc-link" href="#xorshift+">
<div class="vector-toc-text">
<span class="vector-toc-numb">2.3</span>xorshift+</div>
</a>
<ul id="toc-xorshift+-sublist" class="vector-toc-list">
</ul>
</li>
</ul>
</li>
<li id="toc-xoshiro"
class="vector-toc-list-item vector-toc-level-1 vector-toc-list-item-expanded">
<a class="vector-toc-link" href="#xoshiro">
<div class="vector-toc-text">
<span class="vector-toc-numb">3</span>xoshiro</div>
</a>
<button aria-controls="toc-xoshiro-sublist" class="cdx-button cdx-button--weight-quiet cdx-button--icon-only vector-toc-toggle">
<span class="vector-icon vector-icon--x-small mw-ui-icon-wikimedia-expand"></span>
<span>Toggle xoshiro subsection</span>
</button>
<ul id="toc-xoshiro-sublist" class="vector-toc-list">
<li id="toc-xoshiro256**"
class="vector-toc-list-item vector-toc-level-2">
<a class="vector-toc-link" href="#xoshiro256**">
<div class="vector-toc-text">
<span class="vector-toc-numb">3.1</span>xoshiro256**</div>
</a>
<ul id="toc-xoshiro256**-sublist" class="vector-toc-list">
</ul>
</li>
<li id="toc-xoshiro256+"
class="vector-toc-list-item vector-toc-level-2">
<a class="vector-toc-link" href="#xoshiro256+">
<div class="vector-toc-text">
<span class="vector-toc-numb">3.2</span>xoshiro256+</div>
</a>
<ul id="toc-xoshiro256+-sublist" class="vector-toc-list">
</ul>
</li>
<li id="toc-xoroshiro"
class="vector-toc-list-item vector-toc-level-2">
<a class="vector-toc-link" href="#xoroshiro">
<div class="vector-toc-text">
<span class="vector-toc-numb">3.3</span>xoroshiro</div>
</a>
<ul id="toc-xoroshiro-sublist" class="vector-toc-list">
</ul>
</li>
</ul>
</li>
<li id="toc-Initialization"
class="vector-toc-list-item vector-toc-level-1 vector-toc-list-item-expanded">
<a class="vector-toc-link" href="#Initialization">
<div class="vector-toc-text">
<span class="vector-toc-numb">4</span>Initialization</div>
</a>
<ul id="toc-Initialization-sublist" class="vector-toc-list">
</ul>
</li>
<li id="toc-Notes"
class="vector-toc-list-item vector-toc-level-1 vector-toc-list-item-expanded">
<a class="vector-toc-link" href="#Notes">
<div class="vector-toc-text">
<span class="vector-toc-numb">5</span>Notes</div>
</a>
<ul id="toc-Notes-sublist" class="vector-toc-list">
</ul>
</li>
<li id="toc-References"
class="vector-toc-list-item vector-toc-level-1 vector-toc-list-item-expanded">
<a class="vector-toc-link" href="#References">
<div class="vector-toc-text">
<span class="vector-toc-numb">6</span>References</div>
</a>
<ul id="toc-References-sublist" class="vector-toc-list">
</ul>
</li>
<li id="toc-Further_reading"
class="vector-toc-list-item vector-toc-level-1 vector-toc-list-item-expanded">
<a class="vector-toc-link" href="#Further_reading">
<div class="vector-toc-text">
<span class="vector-toc-numb">7</span>Further reading</div>
</a>
<ul id="toc-Further_reading-sublist" class="vector-toc-list">
</ul>
</li>
</ul>
</div>
</div>
</nav>
<div class="mw-content-container">
<main id="content" class="mw-body" role="main">
<header class="mw-body-header vector-page-titlebar">
<nav role="navigation" aria-label="Contents" class="vector-toc-landmark">
<div id="vector-page-titlebar-toc" class="vector-dropdown vector-page-titlebar-toc vector-button-flush-left" >
<input type="checkbox" id="vector-page-titlebar-toc-checkbox" role="button" aria-haspopup="true" data-event-name="ui.dropdown-vector-page-titlebar-toc" class="vector-dropdown-checkbox " aria-label="Toggle the table of contents" >
<label id="vector-page-titlebar-toc-label" for="vector-page-titlebar-toc-checkbox" class="vector-dropdown-label cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet cdx-button--icon-only " aria-hidden="true" ><span class="vector-icon mw-ui-icon-listBullet mw-ui-icon-wikimedia-listBullet"></span>
<span class="vector-dropdown-label-text">Toggle the table of contents</span>
</label>
<div class="vector-dropdown-content">
<div id="vector-page-titlebar-toc-unpinned-container" class="vector-unpinned-container">
</div>
</div>
</div>
</nav>
<h1 id="firstHeading" class="firstHeading mw-first-heading"><span class="mw-page-title-main">Xorshift</span></h1>
<div id="p-lang-btn" class="vector-dropdown mw-portlet mw-portlet-lang" >
<input type="checkbox" id="p-lang-btn-checkbox" role="button" aria-haspopup="true" data-event-name="ui.dropdown-p-lang-btn" class="vector-dropdown-checkbox mw-interlanguage-selector" aria-label="Go to an article in another language. Available in 4 languages" >
<label id="p-lang-btn-label" for="p-lang-btn-checkbox" class="vector-dropdown-label cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet cdx-button--action-progressive mw-portlet-lang-heading-4" aria-hidden="true" ><span class="vector-icon mw-ui-icon-language-progressive mw-ui-icon-wikimedia-language-progressive"></span>
<span class="vector-dropdown-label-text">4 languages</span>
</label>
<div class="vector-dropdown-content">
<div class="vector-menu-content">
<ul class="vector-menu-content-list">
<li class="interlanguage-link interwiki-de mw-list-item"><a href="https://de.wikipedia.org/wiki/Xorshift" title="Xorshift German" lang="de" hreflang="de" class="interlanguage-link-target"><span>Deutsch</span></a></li><li class="interlanguage-link interwiki-ja mw-list-item"><a href="https://ja.wikipedia.org/wiki/Xorshift" title="Xorshift Japanese" lang="ja" hreflang="ja" class="interlanguage-link-target"><span>日本語</span></a></li><li class="interlanguage-link interwiki-pt mw-list-item"><a href="https://pt.wikipedia.org/wiki/Xorshift" title="Xorshift Portuguese" lang="pt" hreflang="pt" class="interlanguage-link-target"><span>Português</span></a></li><li class="interlanguage-link interwiki-ru mw-list-item"><a href="https://ru.wikipedia.org/wiki/Xorshift" title="Xorshift Russian" lang="ru" hreflang="ru" class="interlanguage-link-target"><span>Русский</span></a></li>
</ul>
<div class="after-portlet after-portlet-lang"><span class="wb-langlinks-edit wb-langlinks-link"><a href="https://www.wikidata.org/wiki/Special:EntityPage/Q2576999#sitelinks-wikipedia" title="Edit interlanguage links" class="wbc-editpage">Edit links</a></span></div>
</div>
</div>
</div>
</header>
<div class="vector-page-toolbar">
<div class="vector-page-toolbar-container">
<div id="left-navigation">
<nav aria-label="Namespaces">
<div id="p-associated-pages" class="vector-menu vector-menu-tabs mw-portlet mw-portlet-associated-pages" >
<div class="vector-menu-content">
<ul class="vector-menu-content-list">
<li id="ca-nstab-main" class="selected vector-tab-noicon mw-list-item"><a href="/wiki/Xorshift" title="View the content page [c]" accesskey="c"><span>Article</span></a></li><li id="ca-talk" class="vector-tab-noicon mw-list-item"><a href="/wiki/Talk:Xorshift" rel="discussion" title="Discuss improvements to the content page [t]" accesskey="t"><span>Talk</span></a></li>
</ul>
</div>
</div>
<div id="p-variants" class="vector-dropdown emptyPortlet" >
<input type="checkbox" id="p-variants-checkbox" role="button" aria-haspopup="true" data-event-name="ui.dropdown-p-variants" class="vector-dropdown-checkbox " aria-label="Change language variant" >
<label id="p-variants-label" for="p-variants-checkbox" class="vector-dropdown-label cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet" aria-hidden="true" ><span class="vector-dropdown-label-text">English</span>
</label>
<div class="vector-dropdown-content">
<div id="p-variants" class="vector-menu mw-portlet mw-portlet-variants emptyPortlet" >
<div class="vector-menu-content">
<ul class="vector-menu-content-list">
</ul>
</div>
</div>
</div>
</div>
</nav>
</div>
<div id="right-navigation" class="vector-collapsible">
<nav aria-label="Views">
<div id="p-views" class="vector-menu vector-menu-tabs mw-portlet mw-portlet-views" >
<div class="vector-menu-content">
<ul class="vector-menu-content-list">
<li id="ca-view" class="selected vector-tab-noicon mw-list-item"><a href="/wiki/Xorshift"><span>Read</span></a></li><li id="ca-edit" class="vector-tab-noicon mw-list-item"><a href="/w/index.php?title=Xorshift&amp;action=edit" title="Edit this page [e]" accesskey="e"><span>Edit</span></a></li><li id="ca-history" class="vector-tab-noicon mw-list-item"><a href="/w/index.php?title=Xorshift&amp;action=history" title="Past revisions of this page [h]" accesskey="h"><span>View history</span></a></li>
</ul>
</div>
</div>
</nav>
<nav class="vector-page-tools-landmark" aria-label="Page tools">
<div id="vector-page-tools-dropdown" class="vector-dropdown vector-page-tools-dropdown" >
<input type="checkbox" id="vector-page-tools-dropdown-checkbox" role="button" aria-haspopup="true" data-event-name="ui.dropdown-vector-page-tools-dropdown" class="vector-dropdown-checkbox " aria-label="Tools" >
<label id="vector-page-tools-dropdown-label" for="vector-page-tools-dropdown-checkbox" class="vector-dropdown-label cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet" aria-hidden="true" ><span class="vector-dropdown-label-text">Tools</span>
</label>
<div class="vector-dropdown-content">
<div id="vector-page-tools-unpinned-container" class="vector-unpinned-container">
<div id="vector-page-tools" class="vector-page-tools vector-pinnable-element">
<div
class="vector-pinnable-header vector-page-tools-pinnable-header vector-pinnable-header-unpinned"
data-feature-name="page-tools-pinned"
data-pinnable-element-id="vector-page-tools"
data-pinned-container-id="vector-page-tools-pinned-container"
data-unpinned-container-id="vector-page-tools-unpinned-container"
>
<div class="vector-pinnable-header-label">Tools</div>
<button class="vector-pinnable-header-toggle-button vector-pinnable-header-pin-button" data-event-name="pinnable-header.vector-page-tools.pin">move to sidebar</button>
<button class="vector-pinnable-header-toggle-button vector-pinnable-header-unpin-button" data-event-name="pinnable-header.vector-page-tools.unpin">hide</button>
</div>
<div id="p-cactions" class="vector-menu mw-portlet mw-portlet-cactions emptyPortlet vector-has-collapsible-items" title="More options" >
<div class="vector-menu-heading">
Actions
</div>
<div class="vector-menu-content">
<ul class="vector-menu-content-list">
<li id="ca-more-view" class="selected vector-more-collapsible-item mw-list-item"><a href="/wiki/Xorshift"><span>Read</span></a></li><li id="ca-more-edit" class="vector-more-collapsible-item mw-list-item"><a href="/w/index.php?title=Xorshift&amp;action=edit" title="Edit this page [e]" accesskey="e"><span>Edit</span></a></li><li id="ca-more-history" class="vector-more-collapsible-item mw-list-item"><a href="/w/index.php?title=Xorshift&amp;action=history"><span>View history</span></a></li>
</ul>
</div>
</div>
<div id="p-tb" class="vector-menu mw-portlet mw-portlet-tb" >
<div class="vector-menu-heading">
General
</div>
<div class="vector-menu-content">
<ul class="vector-menu-content-list">
<li id="t-whatlinkshere" class="mw-list-item"><a href="/wiki/Special:WhatLinksHere/Xorshift" title="List of all English Wikipedia pages containing links to this page [j]" accesskey="j"><span>What links here</span></a></li><li id="t-recentchangeslinked" class="mw-list-item"><a href="/wiki/Special:RecentChangesLinked/Xorshift" rel="nofollow" title="Recent changes in pages linked from this page [k]" accesskey="k"><span>Related changes</span></a></li><li id="t-upload" class="mw-list-item"><a href="/wiki/Wikipedia:File_Upload_Wizard" title="Upload files [u]" accesskey="u"><span>Upload file</span></a></li><li id="t-specialpages" class="mw-list-item"><a href="/wiki/Special:SpecialPages" title="A list of all special pages [q]" accesskey="q"><span>Special pages</span></a></li><li id="t-permalink" class="mw-list-item"><a href="/w/index.php?title=Xorshift&amp;oldid=1177332258" title="Permanent link to this revision of this page"><span>Permanent link</span></a></li><li id="t-info" class="mw-list-item"><a href="/w/index.php?title=Xorshift&amp;action=info" title="More information about this page"><span>Page information</span></a></li><li id="t-cite" class="mw-list-item"><a href="/w/index.php?title=Special:CiteThisPage&amp;page=Xorshift&amp;id=1177332258&amp;wpFormIdentifier=titleform" title="Information on how to cite this page"><span>Cite this page</span></a></li><li id="t-urlshortener" class="mw-list-item"><a href="/w/index.php?title=Special:UrlShortener&amp;url=https%3A%2F%2Fen.wikipedia.org%2Fwiki%2FXorshift"><span>Get shortened URL</span></a></li><li id="t-wikibase" class="mw-list-item"><a href="https://www.wikidata.org/wiki/Special:EntityPage/Q2576999" title="Structured data on this page hosted by Wikidata [g]" accesskey="g"><span>Wikidata item</span></a></li>
</ul>
</div>
</div>
<div id="p-coll-print_export" class="vector-menu mw-portlet mw-portlet-coll-print_export" >
<div class="vector-menu-heading">
Print/export
</div>
<div class="vector-menu-content">
<ul class="vector-menu-content-list">
<li id="coll-download-as-rl" class="mw-list-item"><a href="/w/index.php?title=Special:DownloadAsPdf&amp;page=Xorshift&amp;action=show-download-screen" title="Download this page as a PDF file"><span>Download as PDF</span></a></li><li id="t-print" class="mw-list-item"><a href="/w/index.php?title=Xorshift&amp;printable=yes" title="Printable version of this page [p]" accesskey="p"><span>Printable version</span></a></li>
</ul>
</div>
</div>
</div>
</div>
</div>
</div>
</nav>
</div>
</div>
</div>
<div class="vector-column-end">
<nav class="vector-page-tools-landmark vector-sticky-pinned-container" aria-label="Page tools">
<div id="vector-page-tools-pinned-container" class="vector-pinned-container">
</div>
</nav>
</div>
<div id="bodyContent" class="vector-body" aria-labelledby="firstHeading" data-mw-ve-target-container>
<div class="vector-body-before-content">
<div class="mw-indicators">
</div>
<div id="siteSub" class="noprint">From Wikipedia, the free encyclopedia</div>
</div>
<div id="contentSub"><div id="mw-content-subtitle"></div></div>
<div id="mw-content-text" class="mw-body-content"><div class="mw-content-ltr mw-parser-output" lang="en" dir="ltr"><div class="shortdescription nomobile noexcerpt noprint searchaux" style="display:none">Class of pseudorandom number generators</div>
<figure class="mw-default-size mw-halign-right" typeof="mw:File/Thumb"><a href="/wiki/File:Xorshift.png" class="mw-file-description"><img src="//upload.wikimedia.org/wikipedia/commons/thumb/e/ee/Xorshift.png/220px-Xorshift.png" decoding="async" width="220" height="220" class="mw-file-element" srcset="//upload.wikimedia.org/wikipedia/commons/thumb/e/ee/Xorshift.png/330px-Xorshift.png 1.5x, //upload.wikimedia.org/wikipedia/commons/thumb/e/ee/Xorshift.png/440px-Xorshift.png 2x" data-file-width="1024" data-file-height="1024" /></a><figcaption>Example random distribution of Xorshift128</figcaption></figure>
<p><b>Xorshift</b> random number generators, also called <b>shift-register generators</b>, are a class of <a href="/wiki/Pseudorandom_number_generator" title="Pseudorandom number generator">pseudorandom number generators</a> that were invented by <a href="/wiki/George_Marsaglia" title="George Marsaglia">George Marsaglia</a>.<sup id="cite_ref-marsaglia_1-0" class="reference"><a href="#cite_note-marsaglia-1">&#91;1&#93;</a></sup> They are a subset of <a href="/wiki/Linear-feedback_shift_register" title="Linear-feedback shift register">linear-feedback shift registers</a> (LFSRs) which allow a particularly efficient implementation in software without the excessive use of <a href="/wiki/Sparse_polynomial" title="Sparse polynomial">sparse polynomials</a>.<sup id="cite_ref-brent_2-0" class="reference"><a href="#cite_note-brent-2">&#91;2&#93;</a></sup> They generate the next number in their sequence by repeatedly taking the <a href="/wiki/Bitwise_operation#XOR" title="Bitwise operation">exclusive or</a> of a number with a <a href="/wiki/Logical_shift" title="Logical shift">bit-shifted</a> version of itself. This makes execution extremely efficient on modern computer architectures, but it does not benefit efficiency in a hardware implementation. Like all LFSRs, the parameters have to be chosen very carefully in order to achieve a long period.<sup id="cite_ref-panne_3-0" class="reference"><a href="#cite_note-panne-3">&#91;3&#93;</a></sup>
</p><p>For execution in software, xorshift generators are among the fastest PRNGs, requiring very small code and state. However, they do not pass every statistical test without further refinement. This weakness is amended by combining them with a non-linear function, as described in the original paper. Because plain xorshift generators (without a non-linear step) fail some statistical tests, they have been accused of being unreliable.<sup id="cite_ref-panne_3-1" class="reference"><a href="#cite_note-panne-3">&#91;3&#93;</a></sup><sup class="reference nowrap"><span title="Page: 360">&#58;&#8202;360&#8202;</span></sup>
</p>
<meta property="mw:PageProp/toc" />
<h2><span class="mw-headline" id="Example_implementation">Example implementation</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Xorshift&amp;action=edit&amp;section=1" title="Edit section: Example implementation"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></h2>
<p>A <a href="/wiki/C_(programming_language)" title="C (programming language)">C</a> version<sup id="cite_ref-4" class="reference"><a href="#cite_note-4">&#91;a&#93;</a></sup> of three xorshift algorithms<sup id="cite_ref-marsaglia_1-1" class="reference"><a href="#cite_note-marsaglia-1">&#91;1&#93;</a></sup><sup class="reference nowrap"><span title="Page: 4,5">&#58;&#8202;4,5&#8202;</span></sup> is given here. The first has one 32-bit word of state, and period 2<sup>32</sup>1. The second has one 64-bit word of state and period 2<sup>64</sup>1. The last one has four 32-bit words of state, and period 2<sup>128</sup>1. The 128-bit algorithm passes the <a href="/wiki/Diehard_tests" title="Diehard tests">diehard tests</a>. However, it fails the <i>MatrixRank</i> and <i>LinearComp</i> tests of the <i>BigCrush</i> test suite from the <a href="/wiki/TestU01" title="TestU01">TestU01</a> framework.
</p><p>All use three shifts and three or four exclusive-or operations:
</p>
<div class="mw-highlight mw-highlight-lang-c mw-content-ltr" dir="ltr"><pre><span></span><span class="cp">#include</span><span class="w"> </span><span class="cpf">&lt;stdint.h&gt;</span>
<span class="k">struct</span><span class="w"> </span><span class="nc">xorshift32_state</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="kt">uint32_t</span><span class="w"> </span><span class="n">a</span><span class="p">;</span>
<span class="p">};</span>
<span class="cm">/* The state must be initialized to non-zero */</span>
<span class="kt">uint32_t</span><span class="w"> </span><span class="nf">xorshift32</span><span class="p">(</span><span class="k">struct</span><span class="w"> </span><span class="nc">xorshift32_state</span><span class="w"> </span><span class="o">*</span><span class="n">state</span><span class="p">)</span>
<span class="p">{</span>
<span class="w"> </span><span class="cm">/* Algorithm &quot;xor&quot; from p. 4 of Marsaglia, &quot;Xorshift RNGs&quot; */</span>
<span class="w"> </span><span class="kt">uint32_t</span><span class="w"> </span><span class="n">x</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">state</span><span class="o">-&gt;</span><span class="n">a</span><span class="p">;</span>
<span class="w"> </span><span class="n">x</span><span class="w"> </span><span class="o">^=</span><span class="w"> </span><span class="n">x</span><span class="w"> </span><span class="o">&lt;&lt;</span><span class="w"> </span><span class="mi">13</span><span class="p">;</span>
<span class="w"> </span><span class="n">x</span><span class="w"> </span><span class="o">^=</span><span class="w"> </span><span class="n">x</span><span class="w"> </span><span class="o">&gt;&gt;</span><span class="w"> </span><span class="mi">17</span><span class="p">;</span>
<span class="w"> </span><span class="n">x</span><span class="w"> </span><span class="o">^=</span><span class="w"> </span><span class="n">x</span><span class="w"> </span><span class="o">&lt;&lt;</span><span class="w"> </span><span class="mi">5</span><span class="p">;</span>
<span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="n">state</span><span class="o">-&gt;</span><span class="n">a</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">x</span><span class="p">;</span>
<span class="p">}</span>
<span class="k">struct</span><span class="w"> </span><span class="nc">xorshift64_state</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="kt">uint64_t</span><span class="w"> </span><span class="n">a</span><span class="p">;</span>
<span class="p">};</span>
<span class="kt">uint64_t</span><span class="w"> </span><span class="nf">xorshift64</span><span class="p">(</span><span class="k">struct</span><span class="w"> </span><span class="nc">xorshift64_state</span><span class="w"> </span><span class="o">*</span><span class="n">state</span><span class="p">)</span>
<span class="p">{</span>
<span class="w"> </span><span class="kt">uint64_t</span><span class="w"> </span><span class="n">x</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">state</span><span class="o">-&gt;</span><span class="n">a</span><span class="p">;</span>
<span class="w"> </span><span class="n">x</span><span class="w"> </span><span class="o">^=</span><span class="w"> </span><span class="n">x</span><span class="w"> </span><span class="o">&lt;&lt;</span><span class="w"> </span><span class="mi">13</span><span class="p">;</span>
<span class="w"> </span><span class="n">x</span><span class="w"> </span><span class="o">^=</span><span class="w"> </span><span class="n">x</span><span class="w"> </span><span class="o">&gt;&gt;</span><span class="w"> </span><span class="mi">7</span><span class="p">;</span>
<span class="w"> </span><span class="n">x</span><span class="w"> </span><span class="o">^=</span><span class="w"> </span><span class="n">x</span><span class="w"> </span><span class="o">&lt;&lt;</span><span class="w"> </span><span class="mi">17</span><span class="p">;</span>
<span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="n">state</span><span class="o">-&gt;</span><span class="n">a</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">x</span><span class="p">;</span>
<span class="p">}</span>
<span class="cm">/* struct xorshift128_state can alternatively be defined as a pair</span>
<span class="cm"> of uint64_t or a uint128_t where supported */</span>
<span class="k">struct</span><span class="w"> </span><span class="nc">xorshift128_state</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="kt">uint32_t</span><span class="w"> </span><span class="n">x</span><span class="p">[</span><span class="mi">4</span><span class="p">];</span>
<span class="p">};</span>
<span class="cm">/* The state must be initialized to non-zero */</span>
<span class="kt">uint32_t</span><span class="w"> </span><span class="nf">xorshift128</span><span class="p">(</span><span class="k">struct</span><span class="w"> </span><span class="nc">xorshift128_state</span><span class="w"> </span><span class="o">*</span><span class="n">state</span><span class="p">)</span>
<span class="p">{</span>
<span class="w"> </span><span class="cm">/* Algorithm &quot;xor128&quot; from p. 5 of Marsaglia, &quot;Xorshift RNGs&quot; */</span>
<span class="w"> </span><span class="kt">uint32_t</span><span class="w"> </span><span class="n">t</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">state</span><span class="o">-&gt;</span><span class="n">x</span><span class="p">[</span><span class="mi">3</span><span class="p">];</span>
<span class="w"> </span>
<span class="w"> </span><span class="kt">uint32_t</span><span class="w"> </span><span class="n">s</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">state</span><span class="o">-&gt;</span><span class="n">x</span><span class="p">[</span><span class="mi">0</span><span class="p">];</span><span class="w"> </span><span class="cm">/* Perform a contrived 32-bit shift. */</span>
<span class="w"> </span><span class="n">state</span><span class="o">-&gt;</span><span class="n">x</span><span class="p">[</span><span class="mi">3</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">state</span><span class="o">-&gt;</span><span class="n">x</span><span class="p">[</span><span class="mi">2</span><span class="p">];</span>
<span class="w"> </span><span class="n">state</span><span class="o">-&gt;</span><span class="n">x</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">state</span><span class="o">-&gt;</span><span class="n">x</span><span class="p">[</span><span class="mi">1</span><span class="p">];</span>
<span class="w"> </span><span class="n">state</span><span class="o">-&gt;</span><span class="n">x</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">s</span><span class="p">;</span>
<span class="w"> </span><span class="n">t</span><span class="w"> </span><span class="o">^=</span><span class="w"> </span><span class="n">t</span><span class="w"> </span><span class="o">&lt;&lt;</span><span class="w"> </span><span class="mi">11</span><span class="p">;</span>
<span class="w"> </span><span class="n">t</span><span class="w"> </span><span class="o">^=</span><span class="w"> </span><span class="n">t</span><span class="w"> </span><span class="o">&gt;&gt;</span><span class="w"> </span><span class="mi">8</span><span class="p">;</span>
<span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="n">state</span><span class="o">-&gt;</span><span class="n">x</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">t</span><span class="w"> </span><span class="o">^</span><span class="w"> </span><span class="n">s</span><span class="w"> </span><span class="o">^</span><span class="w"> </span><span class="p">(</span><span class="n">s</span><span class="w"> </span><span class="o">&gt;&gt;</span><span class="w"> </span><span class="mi">19</span><span class="p">);</span>
<span class="p">}</span>
</pre></div>
<h2><span class="mw-headline" id="Non-linear_variations">Non-linear variations</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Xorshift&amp;action=edit&amp;section=2" title="Edit section: Non-linear variations"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></h2>
<p>All xorshift generators fail some tests in the <i>BigCrush</i> test suite. This is true for all generators based on linear recurrences, such as the <a href="/wiki/Mersenne_Twister" title="Mersenne Twister">Mersenne Twister</a> or <a href="/wiki/Well_Equidistributed_Long-period_Linear" class="mw-redirect" title="Well Equidistributed Long-period Linear">WELL</a>. However, it is easy to scramble the output of such generators to improve their quality.
</p><p>The scramblers known as <style data-mw-deduplicate="TemplateStyles:r886049734">.mw-parser-output .monospaced{font-family:monospace,monospace}</style><span class="monospaced">+</span> and <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r886049734"><span class="monospaced">*</span> still leave weakness in the low bits,<sup id="cite_ref-Lemire19_5-0" class="reference"><a href="#cite_note-Lemire19-5">&#91;4&#93;</a></sup> so they are intended for floating point use, as double-precision floating-point numbers only use 53 bits, so the lower 11 bits are not used. For general purpose, the scrambler <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r886049734"><span class="monospaced">**</span> (pronounced <i>starstar</i>) makes the LFSR generators pass in all bits.
</p>
<h3><span class="mw-headline" id="xorwow">xorwow</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Xorshift&amp;action=edit&amp;section=3" title="Edit section: xorwow"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></h3>
<p>Marsaglia suggested scrambling the output by combining it with a simple additive counter modulo 2<sup>32</sup> (which he calls a "<a href="/wiki/Weyl_sequence" title="Weyl sequence">Weyl sequence</a>" after <a href="/wiki/Weyl%27s_equidistribution_theorem" class="mw-redirect" title="Weyl&#39;s equidistribution theorem">Weyl's equidistribution theorem</a>). This also increases the period by a factor of 2<sup>32</sup>, to 2<sup>192</sup>2<sup>32</sup>:
</p>
<div class="mw-highlight mw-highlight-lang-c mw-content-ltr" dir="ltr"><pre><span></span><span class="cp">#include</span><span class="w"> </span><span class="cpf">&lt;stdint.h&gt;</span>
<span class="k">struct</span><span class="w"> </span><span class="nc">xorwow_state</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="kt">uint32_t</span><span class="w"> </span><span class="n">x</span><span class="p">[</span><span class="mi">5</span><span class="p">];</span>
<span class="w"> </span><span class="kt">uint32_t</span><span class="w"> </span><span class="n">counter</span><span class="p">;</span>
<span class="p">};</span>
<span class="cm">/* The state array must be initialized to not be all zero in the first four words */</span>
<span class="kt">uint32_t</span><span class="w"> </span><span class="nf">xorwow</span><span class="p">(</span><span class="k">struct</span><span class="w"> </span><span class="nc">xorwow_state</span><span class="w"> </span><span class="o">*</span><span class="n">state</span><span class="p">)</span>
<span class="p">{</span>
<span class="w"> </span><span class="cm">/* Algorithm &quot;xorwow&quot; from p. 5 of Marsaglia, &quot;Xorshift RNGs&quot; */</span>
<span class="w"> </span><span class="kt">uint32_t</span><span class="w"> </span><span class="n">t</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">state</span><span class="o">-&gt;</span><span class="n">x</span><span class="p">[</span><span class="mi">4</span><span class="p">];</span>
<span class="w"> </span>
<span class="w"> </span><span class="kt">uint32_t</span><span class="w"> </span><span class="n">s</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">state</span><span class="o">-&gt;</span><span class="n">x</span><span class="p">[</span><span class="mi">0</span><span class="p">];</span><span class="w"> </span><span class="cm">/* Perform a contrived 32-bit shift. */</span>
<span class="w"> </span><span class="n">state</span><span class="o">-&gt;</span><span class="n">x</span><span class="p">[</span><span class="mi">4</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">state</span><span class="o">-&gt;</span><span class="n">x</span><span class="p">[</span><span class="mi">3</span><span class="p">];</span>
<span class="w"> </span><span class="n">state</span><span class="o">-&gt;</span><span class="n">x</span><span class="p">[</span><span class="mi">3</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">state</span><span class="o">-&gt;</span><span class="n">x</span><span class="p">[</span><span class="mi">2</span><span class="p">];</span>
<span class="w"> </span><span class="n">state</span><span class="o">-&gt;</span><span class="n">x</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">state</span><span class="o">-&gt;</span><span class="n">x</span><span class="p">[</span><span class="mi">1</span><span class="p">];</span>
<span class="w"> </span><span class="n">state</span><span class="o">-&gt;</span><span class="n">x</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">s</span><span class="p">;</span>
<span class="w"> </span>
<span class="w"> </span><span class="n">t</span><span class="w"> </span><span class="o">^=</span><span class="w"> </span><span class="n">t</span><span class="w"> </span><span class="o">&gt;&gt;</span><span class="w"> </span><span class="mi">2</span><span class="p">;</span>
<span class="w"> </span><span class="n">t</span><span class="w"> </span><span class="o">^=</span><span class="w"> </span><span class="n">t</span><span class="w"> </span><span class="o">&lt;&lt;</span><span class="w"> </span><span class="mi">1</span><span class="p">;</span>
<span class="w"> </span><span class="n">t</span><span class="w"> </span><span class="o">^=</span><span class="w"> </span><span class="n">s</span><span class="w"> </span><span class="o">^</span><span class="w"> </span><span class="p">(</span><span class="n">s</span><span class="w"> </span><span class="o">&lt;&lt;</span><span class="w"> </span><span class="mi">4</span><span class="p">);</span>
<span class="w"> </span><span class="n">state</span><span class="o">-&gt;</span><span class="n">x</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">t</span><span class="p">;</span>
<span class="w"> </span><span class="n">state</span><span class="o">-&gt;</span><span class="n">counter</span><span class="w"> </span><span class="o">+=</span><span class="w"> </span><span class="mi">362437</span><span class="p">;</span>
<span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="n">t</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="n">state</span><span class="o">-&gt;</span><span class="n">counter</span><span class="p">;</span>
<span class="p">}</span>
</pre></div>
<p>This performs well, but fails a few tests in BigCrush.<sup id="cite_ref-6" class="reference"><a href="#cite_note-6">&#91;5&#93;</a></sup> This generator is the default in Nvidia's <a href="/wiki/CUDA" title="CUDA">CUDA</a> toolkit.<sup id="cite_ref-7" class="reference"><a href="#cite_note-7">&#91;6&#93;</a></sup>
</p>
<h3><span id="xorshift.2A"></span><span class="mw-headline" id="xorshift*">xorshift*</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Xorshift&amp;action=edit&amp;section=4" title="Edit section: xorshift*"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></h3>
<p>An <em>xorshift*</em> generator applies an invertible multiplication (modulo the word size) as a non-linear transformation to the output of an <em>xorshift</em> generator, as suggested by Marsaglia.<sup id="cite_ref-marsaglia_1-2" class="reference"><a href="#cite_note-marsaglia-1">&#91;1&#93;</a></sup> All <em>xorshift*</em> generators emit a sequence of values that is <a href="/wiki/Equidistributed" class="mw-redirect" title="Equidistributed">equidistributed</a> in the maximum possible dimension (except that they will never output zero for 16 calls, i.e. 128 bytes, in a row).<sup id="cite_ref-vigna_8-0" class="reference"><a href="#cite_note-vigna-8">&#91;7&#93;</a></sup>
</p><p>The following 64-bit generator has a maximal period of 2<sup>64</sup>1.<sup id="cite_ref-vigna_8-1" class="reference"><a href="#cite_note-vigna-8">&#91;7&#93;</a></sup>
</p>
<div class="mw-highlight mw-highlight-lang-c mw-content-ltr" dir="ltr"><pre><span></span><span class="cp">#include</span><span class="w"> </span><span class="cpf">&lt;stdint.h&gt;</span>
<span class="cm">/* xorshift64s, variant A_1(12,25,27) with multiplier M_32 from line 3 of table 5 */</span>
<span class="kt">uint64_t</span><span class="w"> </span><span class="nf">xorshift64star</span><span class="p">(</span><span class="kt">void</span><span class="p">)</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="cm">/* initial seed must be nonzero, don&#39;t use a static variable for the state if multithreaded */</span>
<span class="w"> </span><span class="k">static</span><span class="w"> </span><span class="kt">uint64_t</span><span class="w"> </span><span class="n">x</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">1</span><span class="p">;</span>
<span class="w"> </span><span class="n">x</span><span class="w"> </span><span class="o">^=</span><span class="w"> </span><span class="n">x</span><span class="w"> </span><span class="o">&gt;&gt;</span><span class="w"> </span><span class="mi">12</span><span class="p">;</span>
<span class="w"> </span><span class="n">x</span><span class="w"> </span><span class="o">^=</span><span class="w"> </span><span class="n">x</span><span class="w"> </span><span class="o">&lt;&lt;</span><span class="w"> </span><span class="mi">25</span><span class="p">;</span>
<span class="w"> </span><span class="n">x</span><span class="w"> </span><span class="o">^=</span><span class="w"> </span><span class="n">x</span><span class="w"> </span><span class="o">&gt;&gt;</span><span class="w"> </span><span class="mi">27</span><span class="p">;</span>
<span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="n">x</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="mh">0x2545F4914F6CDD1DULL</span><span class="p">;</span>
<span class="p">}</span>
</pre></div>
<p>The generator fails only the <i>MatrixRank</i> test of BigCrush, however if the generator is modified to return only the high 32 bits, then it passes BigCrush with zero failures.<sup id="cite_ref-PCG_9-0" class="reference"><a href="#cite_note-PCG-9">&#91;8&#93;</a></sup><sup class="reference nowrap"><span title="Page: 7">&#58;&#8202;7&#8202;</span></sup> In fact, a reduced version with only 40 bits of internal state passes the suite, suggesting a large safety margin.<sup id="cite_ref-PCG_9-1" class="reference"><a href="#cite_note-PCG-9">&#91;8&#93;</a></sup><sup class="reference nowrap"><span title="Page: 19">&#58;&#8202;19&#8202;</span></sup> A similar generator suggested in <i><a href="/wiki/Numerical_Recipes" title="Numerical Recipes">Numerical Recipes</a></i><sup id="cite_ref-NR_10-0" class="reference"><a href="#cite_note-NR-10">&#91;9&#93;</a></sup> as <code>RanQ1</code> also fails the <i>BirthdaySpacings</i> test.
</p><p>Vigna<sup id="cite_ref-vigna_8-2" class="reference"><a href="#cite_note-vigna-8">&#91;7&#93;</a></sup> suggests the following <em>xorshift1024*</em> generator with 1024 bits of state and a maximal period of 2<sup>1024</sup>1; however, it does not always pass BigCrush.<sup id="cite_ref-Lemire19_5-1" class="reference"><a href="#cite_note-Lemire19-5">&#91;4&#93;</a></sup> xoshiro256** is therefore a much better option.
</p>
<div class="mw-highlight mw-highlight-lang-c mw-content-ltr" dir="ltr"><pre><span></span><span class="cp">#include</span><span class="w"> </span><span class="cpf">&lt;stdint.h&gt;</span>
<span class="cm">/* The state must be seeded so that there is at least one non-zero element in array */</span>
<span class="k">struct</span><span class="w"> </span><span class="nc">xorshift1024s_state</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="kt">uint64_t</span><span class="w"> </span><span class="n">x</span><span class="p">[</span><span class="mi">16</span><span class="p">];</span>
<span class="w"> </span><span class="kt">int</span><span class="w"> </span><span class="n">index</span><span class="p">;</span>
<span class="p">};</span>
<span class="kt">uint64_t</span><span class="w"> </span><span class="nf">xorshift1024s</span><span class="p">(</span><span class="k">struct</span><span class="w"> </span><span class="nc">xorshift1024s_state</span><span class="w"> </span><span class="o">*</span><span class="n">state</span><span class="p">)</span>
<span class="p">{</span>
<span class="w"> </span><span class="kt">int</span><span class="w"> </span><span class="n">index</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">state</span><span class="o">-&gt;</span><span class="n">index</span><span class="p">;</span>
<span class="w"> </span><span class="kt">uint64_t</span><span class="w"> </span><span class="k">const</span><span class="w"> </span><span class="n">s</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">state</span><span class="o">-&gt;</span><span class="n">x</span><span class="p">[</span><span class="n">index</span><span class="o">++</span><span class="p">];</span>
<span class="w"> </span><span class="kt">uint64_t</span><span class="w"> </span><span class="n">t</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">state</span><span class="o">-&gt;</span><span class="n">x</span><span class="p">[</span><span class="n">index</span><span class="w"> </span><span class="o">&amp;=</span><span class="w"> </span><span class="mi">15</span><span class="p">];</span>
<span class="w"> </span><span class="n">t</span><span class="w"> </span><span class="o">^=</span><span class="w"> </span><span class="n">t</span><span class="w"> </span><span class="o">&lt;&lt;</span><span class="w"> </span><span class="mi">31</span><span class="p">;</span><span class="w"> </span><span class="c1">// a</span>
<span class="w"> </span><span class="n">t</span><span class="w"> </span><span class="o">^=</span><span class="w"> </span><span class="n">t</span><span class="w"> </span><span class="o">&gt;&gt;</span><span class="w"> </span><span class="mi">11</span><span class="p">;</span><span class="w"> </span><span class="c1">// b -- Again, the shifts and the multipliers are tunable</span>
<span class="w"> </span><span class="n">t</span><span class="w"> </span><span class="o">^=</span><span class="w"> </span><span class="n">s</span><span class="w"> </span><span class="o">^</span><span class="w"> </span><span class="p">(</span><span class="n">s</span><span class="w"> </span><span class="o">&gt;&gt;</span><span class="w"> </span><span class="mi">30</span><span class="p">);</span><span class="w"> </span><span class="c1">// c</span>
<span class="w"> </span><span class="n">state</span><span class="o">-&gt;</span><span class="n">x</span><span class="p">[</span><span class="n">index</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">t</span><span class="p">;</span>
<span class="w"> </span><span class="n">state</span><span class="o">-&gt;</span><span class="n">index</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">index</span><span class="p">;</span>
<span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="n">t</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="mi">1181783497276652981ULL</span><span class="p">;</span>
<span class="p">}</span>
</pre></div>
<h3><span id="xorshift.2B"></span><span class="mw-headline" id="xorshift+">xorshift+</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Xorshift&amp;action=edit&amp;section=5" title="Edit section: xorshift+"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></h3>
<p>An <em>xorshift+</em> generator can achieve an order of magnitude fewer failures than <a href="/wiki/Mersenne_Twister" title="Mersenne Twister">Mersenne Twister</a> or <a href="/wiki/Well_equidistributed_long-period_linear" title="Well equidistributed long-period linear">WELL</a>. A native C implementation of an xorshift+ generator that passes all tests from the BigCrush suite can typically generate a random number in fewer than 10 <a href="/wiki/Clock_cycle" class="mw-redirect" title="Clock cycle">clock cycles</a> on <a href="/wiki/X86" title="X86">x86</a>, thanks to <a href="/wiki/Instruction_pipelining" title="Instruction pipelining">instruction pipelining</a>.<sup id="cite_ref-shootout_11-0" class="reference"><a href="#cite_note-shootout-11">&#91;10&#93;</a></sup>
</p><p>Rather than using multiplication, it is possible to use addition as a faster non-linear transformation. The idea was first proposed by Saito and Matsumoto (also responsible for the Mersenne Twister) in the <em>XSadd</em> generator, which adds two consecutive outputs of an underlying <em>xorshift</em> generator based on 32-bit shifts.<sup id="cite_ref-xsadd_12-0" class="reference"><a href="#cite_note-xsadd-12">&#91;11&#93;</a></sup> However, one disadvantage of adding consecutive outputs is that, while the underlying <em>xorshift128</em> generator is 2-dimensionally equidistributed, the <em>xorshift128+</em> generator is only 1-dimensionally equidistributed.<sup id="cite_ref-vigna2_13-0" class="reference"><a href="#cite_note-vigna2-13">&#91;12&#93;</a></sup>
</p><p><em>XSadd</em> has some weakness in the low-order bits of its output; it fails several BigCrush tests when the output words are bit-reversed. To correct this problem, Vigna introduced the <em>xorshift+</em> family,<sup id="cite_ref-vigna2_13-1" class="reference"><a href="#cite_note-vigna2-13">&#91;12&#93;</a></sup> based on 64-bit shifts. <em>xorshift+</em> generators, even as large as <em>xorshift1024+</em>, exhibit some detectable linearity in the low-order bits of their output;<sup id="cite_ref-Lemire19_5-2" class="reference"><a href="#cite_note-Lemire19-5">&#91;4&#93;</a></sup> it passes BigCrush, but doesn't when the 32 lowest-order bits are used in reverse order from each 64-bit word.<sup id="cite_ref-Lemire19_5-3" class="reference"><a href="#cite_note-Lemire19-5">&#91;4&#93;</a></sup> This generator is one of the fastest generators passing BigCrush.<sup id="cite_ref-shootout_11-1" class="reference"><a href="#cite_note-shootout-11">&#91;10&#93;</a></sup>
</p><p>The following <em>xorshift128+</em> generator uses 128 bits of state and has a maximal period of 2<sup>128</sup>1.
</p>
<div class="mw-highlight mw-highlight-lang-c mw-content-ltr" dir="ltr"><pre><span></span><span class="cp">#include</span><span class="w"> </span><span class="cpf">&lt;stdint.h&gt;</span>
<span class="k">struct</span><span class="w"> </span><span class="nc">xorshift128p_state</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="kt">uint64_t</span><span class="w"> </span><span class="n">x</span><span class="p">[</span><span class="mi">2</span><span class="p">];</span>
<span class="p">};</span>
<span class="cm">/* The state must be seeded so that it is not all zero */</span>
<span class="kt">uint64_t</span><span class="w"> </span><span class="nf">xorshift128p</span><span class="p">(</span><span class="k">struct</span><span class="w"> </span><span class="nc">xorshift128p_state</span><span class="w"> </span><span class="o">*</span><span class="n">state</span><span class="p">)</span>
<span class="p">{</span>
<span class="w"> </span><span class="kt">uint64_t</span><span class="w"> </span><span class="n">t</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">state</span><span class="o">-&gt;</span><span class="n">x</span><span class="p">[</span><span class="mi">0</span><span class="p">];</span>
<span class="w"> </span><span class="kt">uint64_t</span><span class="w"> </span><span class="k">const</span><span class="w"> </span><span class="n">s</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">state</span><span class="o">-&gt;</span><span class="n">x</span><span class="p">[</span><span class="mi">1</span><span class="p">];</span>
<span class="w"> </span><span class="n">state</span><span class="o">-&gt;</span><span class="n">x</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">s</span><span class="p">;</span>
<span class="w"> </span><span class="n">t</span><span class="w"> </span><span class="o">^=</span><span class="w"> </span><span class="n">t</span><span class="w"> </span><span class="o">&lt;&lt;</span><span class="w"> </span><span class="mi">23</span><span class="p">;</span><span class="w"> </span><span class="c1">// a</span>
<span class="w"> </span><span class="n">t</span><span class="w"> </span><span class="o">^=</span><span class="w"> </span><span class="n">t</span><span class="w"> </span><span class="o">&gt;&gt;</span><span class="w"> </span><span class="mi">18</span><span class="p">;</span><span class="w"> </span><span class="c1">// b -- Again, the shifts and the multipliers are tunable</span>
<span class="w"> </span><span class="n">t</span><span class="w"> </span><span class="o">^=</span><span class="w"> </span><span class="n">s</span><span class="w"> </span><span class="o">^</span><span class="w"> </span><span class="p">(</span><span class="n">s</span><span class="w"> </span><span class="o">&gt;&gt;</span><span class="w"> </span><span class="mi">5</span><span class="p">);</span><span class="w"> </span><span class="c1">// c</span>
<span class="w"> </span><span class="n">state</span><span class="o">-&gt;</span><span class="n">x</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">t</span><span class="p">;</span>
<span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="n">t</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="n">s</span><span class="p">;</span>
<span class="p">}</span>
</pre></div>
<h2><span class="mw-headline" id="xoshiro">xoshiro</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Xorshift&amp;action=edit&amp;section=6" title="Edit section: xoshiro"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></h2>
<p>xoshiro and xoroshiro use rotations in addition to shifts. According to Vigna, they are faster and produce better quality output than xorshift.<sup id="cite_ref-xoshiro-web_14-0" class="reference"><a href="#cite_note-xoshiro-web-14">&#91;13&#93;</a></sup><sup id="cite_ref-xoshiro-paper_15-0" class="reference"><a href="#cite_note-xoshiro-paper-15">&#91;14&#93;</a></sup>
</p><p>This class of generator has variants for 32-bit and 64-bit integer and floating point output; for floating point, one takes the upper 53 bits (for <a href="/wiki/Double-precision_floating-point_format" title="Double-precision floating-point format">binary64</a>) or the upper 23 bits (for <a href="/wiki/Single-precision_floating-point_format" title="Single-precision floating-point format">binary32</a>), since the upper bits are of better quality than the lower bits in the floating point generators. The algorithms also include a <code>jump</code> function, which sets the state forward by some number of steps usually a power of two that allows many <a href="/wiki/Thread_(computing)" title="Thread (computing)">threads of execution</a> to start at distinct initial states.
</p><p>For 32-bit output, xoshiro128** and xoshiro128+ are exactly equivalent to xoshiro256** and xoshiro256+, with <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r886049734"><span class="monospaced">uint32_t</span> in place of <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r886049734"><span class="monospaced">uint64_t</span>, and with different shift/rotate constants.
</p><p>More recently, the <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r886049734"><span class="monospaced">xoshiro++</span> generators have been made as an alternative to the <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r886049734"><span class="monospaced">xoshiro**</span> generators. They are used in some implementations of <a href="/wiki/Fortran" title="Fortran">Fortran</a> compilers such as GNU Fortran, <a href="/wiki/Java_(programming_language)" title="Java (programming language)">Java</a>, and <a href="/wiki/Julia_(programming_language)" title="Julia (programming language)">Julia</a>.<sup id="cite_ref-xoshiro_16-0" class="reference"><a href="#cite_note-xoshiro-16">&#91;15&#93;</a></sup>
</p>
<h3><span id="xoshiro256.2A.2A"></span><span class="mw-headline" id="xoshiro256**">xoshiro256**</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Xorshift&amp;action=edit&amp;section=7" title="Edit section: xoshiro256**"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></h3>
<p>xoshiro256** is the family's general-purpose random 64-bit number generator. It is used in <a href="/wiki/GNU_Fortran" title="GNU Fortran">GNU Fortran</a> <a href="/wiki/Compiler" title="Compiler">compiler</a>, <a href="/wiki/Lua_(programming_language)" title="Lua (programming language)">Lua</a> (as of Lua 5.4), and the <a href="/wiki/.NET" title=".NET">.NET</a> framework (as of .NET 6.0).<sup id="cite_ref-xoshiro_16-1" class="reference"><a href="#cite_note-xoshiro-16">&#91;15&#93;</a></sup>
</p>
<div class="mw-highlight mw-highlight-lang-c mw-content-ltr" dir="ltr"><pre><span></span><span class="cm">/* Adapted from the code included on Sebastiano Vigna&#39;s website */</span>
<span class="cp">#include</span><span class="w"> </span><span class="cpf">&lt;stdint.h&gt;</span>
<span class="kt">uint64_t</span><span class="w"> </span><span class="nf">rol64</span><span class="p">(</span><span class="kt">uint64_t</span><span class="w"> </span><span class="n">x</span><span class="p">,</span><span class="w"> </span><span class="kt">int</span><span class="w"> </span><span class="n">k</span><span class="p">)</span>
<span class="p">{</span>
<span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="p">(</span><span class="n">x</span><span class="w"> </span><span class="o">&lt;&lt;</span><span class="w"> </span><span class="n">k</span><span class="p">)</span><span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="p">(</span><span class="n">x</span><span class="w"> </span><span class="o">&gt;&gt;</span><span class="w"> </span><span class="p">(</span><span class="mi">64</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="n">k</span><span class="p">));</span>
<span class="p">}</span>
<span class="k">struct</span><span class="w"> </span><span class="nc">xoshiro256ss_state</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="kt">uint64_t</span><span class="w"> </span><span class="n">s</span><span class="p">[</span><span class="mi">4</span><span class="p">];</span>
<span class="p">};</span>
<span class="kt">uint64_t</span><span class="w"> </span><span class="nf">xoshiro256ss</span><span class="p">(</span><span class="k">struct</span><span class="w"> </span><span class="nc">xoshiro256ss_state</span><span class="w"> </span><span class="o">*</span><span class="n">state</span><span class="p">)</span>
<span class="p">{</span>
<span class="w"> </span><span class="kt">uint64_t</span><span class="w"> </span><span class="o">*</span><span class="n">s</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">state</span><span class="o">-&gt;</span><span class="n">s</span><span class="p">;</span>
<span class="w"> </span><span class="kt">uint64_t</span><span class="w"> </span><span class="k">const</span><span class="w"> </span><span class="n">result</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">rol64</span><span class="p">(</span><span class="n">s</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="mi">5</span><span class="p">,</span><span class="w"> </span><span class="mi">7</span><span class="p">)</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="mi">9</span><span class="p">;</span>
<span class="w"> </span><span class="kt">uint64_t</span><span class="w"> </span><span class="k">const</span><span class="w"> </span><span class="n">t</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">s</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="w"> </span><span class="o">&lt;&lt;</span><span class="w"> </span><span class="mi">17</span><span class="p">;</span>
<span class="w"> </span><span class="n">s</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span><span class="w"> </span><span class="o">^=</span><span class="w"> </span><span class="n">s</span><span class="p">[</span><span class="mi">0</span><span class="p">];</span>
<span class="w"> </span><span class="n">s</span><span class="p">[</span><span class="mi">3</span><span class="p">]</span><span class="w"> </span><span class="o">^=</span><span class="w"> </span><span class="n">s</span><span class="p">[</span><span class="mi">1</span><span class="p">];</span>
<span class="w"> </span><span class="n">s</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="w"> </span><span class="o">^=</span><span class="w"> </span><span class="n">s</span><span class="p">[</span><span class="mi">2</span><span class="p">];</span>
<span class="w"> </span><span class="n">s</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="w"> </span><span class="o">^=</span><span class="w"> </span><span class="n">s</span><span class="p">[</span><span class="mi">3</span><span class="p">];</span>
<span class="w"> </span><span class="n">s</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span><span class="w"> </span><span class="o">^=</span><span class="w"> </span><span class="n">t</span><span class="p">;</span>
<span class="w"> </span><span class="n">s</span><span class="p">[</span><span class="mi">3</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">rol64</span><span class="p">(</span><span class="n">s</span><span class="p">[</span><span class="mi">3</span><span class="p">],</span><span class="w"> </span><span class="mi">45</span><span class="p">);</span>
<span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="n">result</span><span class="p">;</span>
<span class="p">}</span>
</pre></div>
<h3><span id="xoshiro256.2B"></span><span class="mw-headline" id="xoshiro256+">xoshiro256+</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Xorshift&amp;action=edit&amp;section=8" title="Edit section: xoshiro256+"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></h3>
<p>xoshiro256+ is approximately 15% faster than xoshiro256**, but the lowest three bits have low linear complexity; therefore, it should be used only for floating point results by extracting the upper 53 bits.
</p>
<div class="mw-highlight mw-highlight-lang-c mw-content-ltr" dir="ltr"><pre><span></span><span class="cp">#include</span><span class="w"> </span><span class="cpf">&lt;stdint.h&gt;</span>
<span class="kt">uint64_t</span><span class="w"> </span><span class="nf">rol64</span><span class="p">(</span><span class="kt">uint64_t</span><span class="w"> </span><span class="n">x</span><span class="p">,</span><span class="w"> </span><span class="kt">int</span><span class="w"> </span><span class="n">k</span><span class="p">)</span>
<span class="p">{</span>
<span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="p">(</span><span class="n">x</span><span class="w"> </span><span class="o">&lt;&lt;</span><span class="w"> </span><span class="n">k</span><span class="p">)</span><span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="p">(</span><span class="n">x</span><span class="w"> </span><span class="o">&gt;&gt;</span><span class="w"> </span><span class="p">(</span><span class="mi">64</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="n">k</span><span class="p">));</span>
<span class="p">}</span>
<span class="k">struct</span><span class="w"> </span><span class="nc">xoshiro256p_state</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="kt">uint64_t</span><span class="w"> </span><span class="n">s</span><span class="p">[</span><span class="mi">4</span><span class="p">];</span>
<span class="p">};</span>
<span class="kt">uint64_t</span><span class="w"> </span><span class="nf">xoshiro256p</span><span class="p">(</span><span class="k">struct</span><span class="w"> </span><span class="nc">xoshiro256p_state</span><span class="w"> </span><span class="o">*</span><span class="n">state</span><span class="p">)</span>
<span class="p">{</span>
<span class="w"> </span><span class="kt">uint64_t</span><span class="o">*</span><span class="w"> </span><span class="n">s</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">state</span><span class="o">-&gt;</span><span class="n">s</span><span class="p">;</span>
<span class="w"> </span><span class="kt">uint64_t</span><span class="w"> </span><span class="k">const</span><span class="w"> </span><span class="n">result</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">s</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="n">s</span><span class="p">[</span><span class="mi">3</span><span class="p">];</span>
<span class="w"> </span><span class="kt">uint64_t</span><span class="w"> </span><span class="k">const</span><span class="w"> </span><span class="n">t</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">s</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="w"> </span><span class="o">&lt;&lt;</span><span class="w"> </span><span class="mi">17</span><span class="p">;</span>
<span class="w"> </span><span class="n">s</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span><span class="w"> </span><span class="o">^=</span><span class="w"> </span><span class="n">s</span><span class="p">[</span><span class="mi">0</span><span class="p">];</span>
<span class="w"> </span><span class="n">s</span><span class="p">[</span><span class="mi">3</span><span class="p">]</span><span class="w"> </span><span class="o">^=</span><span class="w"> </span><span class="n">s</span><span class="p">[</span><span class="mi">1</span><span class="p">];</span>
<span class="w"> </span><span class="n">s</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="w"> </span><span class="o">^=</span><span class="w"> </span><span class="n">s</span><span class="p">[</span><span class="mi">2</span><span class="p">];</span>
<span class="w"> </span><span class="n">s</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="w"> </span><span class="o">^=</span><span class="w"> </span><span class="n">s</span><span class="p">[</span><span class="mi">3</span><span class="p">];</span>
<span class="w"> </span><span class="n">s</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span><span class="w"> </span><span class="o">^=</span><span class="w"> </span><span class="n">t</span><span class="p">;</span>
<span class="w"> </span><span class="n">s</span><span class="p">[</span><span class="mi">3</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">rol64</span><span class="p">(</span><span class="n">s</span><span class="p">[</span><span class="mi">3</span><span class="p">],</span><span class="w"> </span><span class="mi">45</span><span class="p">);</span>
<span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="n">result</span><span class="p">;</span>
<span class="p">}</span>
</pre></div>
<h3><span class="mw-headline" id="xoroshiro">xoroshiro</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Xorshift&amp;action=edit&amp;section=9" title="Edit section: xoroshiro"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></h3>
<p>If space is at a premium, xoroshiro128** and xoroshiro128+ are equivalent to xoshiro256** and xoshiro256+. These have smaller state spaces, and thus are less useful for massively parallel programs. xoroshiro128+ also exhibits a mild dependency in the <a href="/wiki/Hamming_weight" title="Hamming weight">population count</a>, generating a failure after <span class="nowrap"><span data-sort-value="7013400000000000000♠"></span>5&#160;<a href="/wiki/Terabyte" class="mw-redirect" title="Terabyte">TB</a></span> of output. The authors do not believe that this can be detected in real world programs.
</p><p>xoroshiro64** and xoroshiro64* are equivalent to xoroshiro128** and xoroshiro128+. Unlike the xoshiro generators, they are not straightforward ports of their higher-precision counterparts.
</p>
<h2><span class="mw-headline" id="Initialization">Initialization</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Xorshift&amp;action=edit&amp;section=10" title="Edit section: Initialization"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></h2>
<p>In the xoshiro paper, it is recommended to initialize the state of the generators using a generator which is radically different from the initialized generators, as well as one which will never give the "all-zero" state; for shift-register generators, this state is impossible to escape from.<sup id="cite_ref-xoshiro-paper_15-1" class="reference"><a href="#cite_note-xoshiro-paper-15">&#91;14&#93;</a></sup><sup id="cite_ref-initialization_17-0" class="reference"><a href="#cite_note-initialization-17">&#91;16&#93;</a></sup> The authors specifically recommend using the SplitMix64 generator, from a 64-bit seed, as follows:
</p>
<div class="mw-highlight mw-highlight-lang-c mw-content-ltr" dir="ltr"><pre><span></span><span class="cp">#include</span><span class="w"> </span><span class="cpf">&lt;stdint.h&gt;</span>
<span class="k">struct</span><span class="w"> </span><span class="nc">splitmix64_state</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="kt">uint64_t</span><span class="w"> </span><span class="n">s</span><span class="p">;</span>
<span class="p">};</span>
<span class="kt">uint64_t</span><span class="w"> </span><span class="nf">splitmix64</span><span class="p">(</span><span class="k">struct</span><span class="w"> </span><span class="nc">splitmix64_state</span><span class="w"> </span><span class="o">*</span><span class="n">state</span><span class="p">)</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="kt">uint64_t</span><span class="w"> </span><span class="n">result</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">(</span><span class="n">state</span><span class="o">-&gt;</span><span class="n">s</span><span class="w"> </span><span class="o">+=</span><span class="w"> </span><span class="mh">0x9E3779B97f4A7C15</span><span class="p">);</span>
<span class="w"> </span><span class="n">result</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">(</span><span class="n">result</span><span class="w"> </span><span class="o">^</span><span class="w"> </span><span class="p">(</span><span class="n">result</span><span class="w"> </span><span class="o">&gt;&gt;</span><span class="w"> </span><span class="mi">30</span><span class="p">))</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="mh">0xBF58476D1CE4E5B9</span><span class="p">;</span>
<span class="w"> </span><span class="n">result</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">(</span><span class="n">result</span><span class="w"> </span><span class="o">^</span><span class="w"> </span><span class="p">(</span><span class="n">result</span><span class="w"> </span><span class="o">&gt;&gt;</span><span class="w"> </span><span class="mi">27</span><span class="p">))</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="mh">0x94D049BB133111EB</span><span class="p">;</span>
<span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="n">result</span><span class="w"> </span><span class="o">^</span><span class="w"> </span><span class="p">(</span><span class="n">result</span><span class="w"> </span><span class="o">&gt;&gt;</span><span class="w"> </span><span class="mi">31</span><span class="p">);</span>
<span class="p">}</span>
<span class="k">struct</span><span class="w"> </span><span class="nc">xorshift128_state</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="kt">uint32_t</span><span class="w"> </span><span class="n">x</span><span class="p">[</span><span class="mi">4</span><span class="p">];</span>
<span class="p">};</span>
<span class="c1">// one could do the same for any of the other generators</span>
<span class="kt">void</span><span class="w"> </span><span class="nf">xorshift128_init</span><span class="p">(</span><span class="k">struct</span><span class="w"> </span><span class="nc">xorshift128_state</span><span class="w"> </span><span class="o">*</span><span class="n">state</span><span class="p">,</span><span class="w"> </span><span class="kt">uint64_t</span><span class="w"> </span><span class="n">seed</span><span class="p">)</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="k">struct</span><span class="w"> </span><span class="nc">splitmix64_state</span><span class="w"> </span><span class="n">smstate</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">{</span><span class="n">seed</span><span class="p">};</span>
<span class="w"> </span><span class="kt">uint64_t</span><span class="w"> </span><span class="n">tmp</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">splitmix64</span><span class="p">(</span><span class="o">&amp;</span><span class="n">smstate</span><span class="p">);</span>
<span class="w"> </span><span class="n">state</span><span class="o">-&gt;</span><span class="n">x</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">(</span><span class="kt">uint32_t</span><span class="p">)</span><span class="n">tmp</span><span class="p">;</span>
<span class="w"> </span><span class="n">state</span><span class="o">-&gt;</span><span class="n">x</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">(</span><span class="kt">uint32_t</span><span class="p">)(</span><span class="n">tmp</span><span class="w"> </span><span class="o">&gt;&gt;</span><span class="w"> </span><span class="mi">32</span><span class="p">);</span>
<span class="w"> </span><span class="n">tmp</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">splitmix64</span><span class="p">(</span><span class="o">&amp;</span><span class="n">smstate</span><span class="p">);</span>
<span class="w"> </span><span class="n">state</span><span class="o">-&gt;</span><span class="n">x</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">(</span><span class="kt">uint32_t</span><span class="p">)</span><span class="n">tmp</span><span class="p">;</span>
<span class="w"> </span><span class="n">state</span><span class="o">-&gt;</span><span class="n">x</span><span class="p">[</span><span class="mi">3</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">(</span><span class="kt">uint32_t</span><span class="p">)(</span><span class="n">tmp</span><span class="w"> </span><span class="o">&gt;&gt;</span><span class="w"> </span><span class="mi">32</span><span class="p">);</span>
<span class="p">}</span>
</pre></div>
<h2><span class="mw-headline" id="Notes">Notes</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Xorshift&amp;action=edit&amp;section=11" title="Edit section: Notes"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></h2>
<style data-mw-deduplicate="TemplateStyles:r1011085734">.mw-parser-output .reflist{font-size:90%;margin-bottom:0.5em;list-style-type:decimal}.mw-parser-output .reflist .references{font-size:100%;margin-bottom:0;list-style-type:inherit}.mw-parser-output .reflist-columns-2{column-width:30em}.mw-parser-output .reflist-columns-3{column-width:25em}.mw-parser-output .reflist-columns{margin-top:0.3em}.mw-parser-output .reflist-columns ol{margin-top:0}.mw-parser-output .reflist-columns li{page-break-inside:avoid;break-inside:avoid-column}.mw-parser-output .reflist-upper-alpha{list-style-type:upper-alpha}.mw-parser-output .reflist-upper-roman{list-style-type:upper-roman}.mw-parser-output .reflist-lower-alpha{list-style-type:lower-alpha}.mw-parser-output .reflist-lower-greek{list-style-type:lower-greek}.mw-parser-output .reflist-lower-roman{list-style-type:lower-roman}</style><div class="reflist reflist-lower-alpha">
<div class="mw-references-wrap"><ol class="references">
<li id="cite_note-4"><span class="mw-cite-backlink"><b><a href="#cite_ref-4">^</a></b></span> <span class="reference-text">In C and most other C-based languages, <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" id="" style="" dir="ltr">^</code> represents <a href="/wiki/Bitwise_operation#XOR" title="Bitwise operation">bitwise XOR</a>, and <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" id="" style="" dir="ltr">&lt;&lt;</code> and <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" id="" style="" dir="ltr">&gt;&gt;</code> represent <a href="/wiki/Logical_shift" title="Logical shift">bitwise shifts</a>.</span>
</li>
</ol></div></div>
<h2><span class="mw-headline" id="References">References</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Xorshift&amp;action=edit&amp;section=12" title="Edit section: References"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></h2>
<link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1011085734"><div class="reflist">
<div class="mw-references-wrap mw-references-columns"><ol class="references">
<li id="cite_note-marsaglia-1"><span class="mw-cite-backlink">^ <a href="#cite_ref-marsaglia_1-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-marsaglia_1-1"><sup><i><b>b</b></i></sup></a> <a href="#cite_ref-marsaglia_1-2"><sup><i><b>c</b></i></sup></a></span> <span class="reference-text"><style data-mw-deduplicate="TemplateStyles:r1133582631">.mw-parser-output cite.citation{font-style:inherit;word-wrap:break-word}.mw-parser-output .citation q{quotes:"\"""\"""'""'"}.mw-parser-output .citation:target{background-color:rgba(0,127,255,0.133)}.mw-parser-output .id-lock-free a,.mw-parser-output .citation .cs1-lock-free a{background:url("//upload.wikimedia.org/wikipedia/commons/6/65/Lock-green.svg")right 0.1em center/9px no-repeat}.mw-parser-output .id-lock-limited a,.mw-parser-output .id-lock-registration a,.mw-parser-output .citation .cs1-lock-limited a,.mw-parser-output .citation .cs1-lock-registration a{background:url("//upload.wikimedia.org/wikipedia/commons/d/d6/Lock-gray-alt-2.svg")right 0.1em center/9px no-repeat}.mw-parser-output .id-lock-subscription a,.mw-parser-output .citation .cs1-lock-subscription a{background:url("//upload.wikimedia.org/wikipedia/commons/a/aa/Lock-red-alt-2.svg")right 0.1em center/9px no-repeat}.mw-parser-output .cs1-ws-icon a{background:url("//upload.wikimedia.org/wikipedia/commons/4/4c/Wikisource-logo.svg")right 0.1em center/12px no-repeat}.mw-parser-output .cs1-code{color:inherit;background:inherit;border:none;padding:inherit}.mw-parser-output .cs1-hidden-error{display:none;color:#d33}.mw-parser-output .cs1-visible-error{color:#d33}.mw-parser-output .cs1-maint{display:none;color:#3a3;margin-left:0.3em}.mw-parser-output .cs1-format{font-size:95%}.mw-parser-output .cs1-kern-left{padding-left:0.2em}.mw-parser-output .cs1-kern-right{padding-right:0.2em}.mw-parser-output .citation .mw-selflink{font-weight:inherit}</style><cite id="CITEREFMarsaglia2003" class="citation journal cs1"><a href="/wiki/George_Marsaglia" title="George Marsaglia">Marsaglia, George</a> (July 2003). <a rel="nofollow" class="external text" href="https://doi.org/10.18637%2Fjss.v008.i14">"Xorshift RNGs"</a>. <i><a href="/wiki/Journal_of_Statistical_Software" title="Journal of Statistical Software">Journal of Statistical Software</a></i>. <b>8</b> (14). <a href="/wiki/Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<span class="cs1-lock-free" title="Freely accessible"><a rel="nofollow" class="external text" href="https://doi.org/10.18637%2Fjss.v008.i14">10.18637/jss.v008.i14</a></span>.</cite><span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&amp;rft.genre=article&amp;rft.jtitle=Journal+of+Statistical+Software&amp;rft.atitle=Xorshift+RNGs&amp;rft.volume=8&amp;rft.issue=14&amp;rft.date=2003-07&amp;rft_id=info%3Adoi%2F10.18637%2Fjss.v008.i14&amp;rft.aulast=Marsaglia&amp;rft.aufirst=George&amp;rft_id=https%3A%2F%2Fdoi.org%2F10.18637%252Fjss.v008.i14&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3AXorshift" class="Z3988"></span></span>
</li>
<li id="cite_note-brent-2"><span class="mw-cite-backlink"><b><a href="#cite_ref-brent_2-0">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1133582631"><cite id="CITEREFBrent2004" class="citation journal cs1"><a href="/wiki/Richard_P._Brent" title="Richard P. Brent">Brent, Richard P.</a> (August 2004). <a rel="nofollow" class="external text" href="https://doi.org/10.18637%2Fjss.v011.i05">"Note on Marsaglia's Xorshift Random Number Generators"</a>. <i><a href="/wiki/Journal_of_Statistical_Software" title="Journal of Statistical Software">Journal of Statistical Software</a></i>. <b>11</b> (5). <a href="/wiki/Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<span class="cs1-lock-free" title="Freely accessible"><a rel="nofollow" class="external text" href="https://doi.org/10.18637%2Fjss.v011.i05">10.18637/jss.v011.i05</a></span>. <a href="/wiki/Hdl_(identifier)" class="mw-redirect" title="Hdl (identifier)">hdl</a>:<span class="cs1-lock-free" title="Freely accessible"><a rel="nofollow" class="external text" href="https://hdl.handle.net/1885%2F34049">1885/34049</a></span>.</cite><span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&amp;rft.genre=article&amp;rft.jtitle=Journal+of+Statistical+Software&amp;rft.atitle=Note+on+Marsaglia%27s+Xorshift+Random+Number+Generators&amp;rft.volume=11&amp;rft.issue=5&amp;rft.date=2004-08&amp;rft_id=info%3Ahdl%2F1885%2F34049&amp;rft_id=info%3Adoi%2F10.18637%2Fjss.v011.i05&amp;rft.aulast=Brent&amp;rft.aufirst=Richard+P.&amp;rft_id=https%3A%2F%2Fdoi.org%2F10.18637%252Fjss.v011.i05&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3AXorshift" class="Z3988"></span></span>
</li>
<li id="cite_note-panne-3"><span class="mw-cite-backlink">^ <a href="#cite_ref-panne_3-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-panne_3-1"><sup><i><b>b</b></i></sup></a></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1133582631"><cite id="CITEREFPannetonL&#39;Ecuyer2005" class="citation journal cs1">Panneton, François; L'Ecuyer, Pierre (October 2005). <a rel="nofollow" class="external text" href="https://www.iro.umontreal.ca/~lecuyer/myftp/papers/xorshift.pdf">"On the xorshift random number generators"</a> <span class="cs1-format">(PDF)</span>. <i>ACM Transactions on Modeling and Computer Simulation</i>. <b>15</b> (4): 346361. <a href="/wiki/Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<a rel="nofollow" class="external text" href="https://doi.org/10.1145%2F1113316.1113319">10.1145/1113316.1113319</a>. <a href="/wiki/S2CID_(identifier)" class="mw-redirect" title="S2CID (identifier)">S2CID</a>&#160;<a rel="nofollow" class="external text" href="https://api.semanticscholar.org/CorpusID:11136098">11136098</a>.</cite><span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&amp;rft.genre=article&amp;rft.jtitle=ACM+Transactions+on+Modeling+and+Computer+Simulation&amp;rft.atitle=On+the+xorshift+random+number+generators&amp;rft.volume=15&amp;rft.issue=4&amp;rft.pages=346-361&amp;rft.date=2005-10&amp;rft_id=info%3Adoi%2F10.1145%2F1113316.1113319&amp;rft_id=https%3A%2F%2Fapi.semanticscholar.org%2FCorpusID%3A11136098%23id-name%3DS2CID&amp;rft.aulast=Panneton&amp;rft.aufirst=Fran%C3%A7ois&amp;rft.au=L%27Ecuyer%2C+Pierre&amp;rft_id=https%3A%2F%2Fwww.iro.umontreal.ca%2F~lecuyer%2Fmyftp%2Fpapers%2Fxorshift.pdf&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3AXorshift" class="Z3988"></span></span>
</li>
<li id="cite_note-Lemire19-5"><span class="mw-cite-backlink">^ <a href="#cite_ref-Lemire19_5-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-Lemire19_5-1"><sup><i><b>b</b></i></sup></a> <a href="#cite_ref-Lemire19_5-2"><sup><i><b>c</b></i></sup></a> <a href="#cite_ref-Lemire19_5-3"><sup><i><b>d</b></i></sup></a></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1133582631"><cite id="CITEREFLemireONeill2019" class="citation journal cs1">Lemire, Daniel; ONeill, Melissa E. (April 2019). "Xorshift1024*, Xorshift1024+, Xorshift128+ and Xoroshiro128+ Fail Statistical Tests for Linearity". <i>Computational and Applied Mathematics</i>. <b>350</b>: 139142. <a href="/wiki/ArXiv_(identifier)" class="mw-redirect" title="ArXiv (identifier)">arXiv</a>:<span class="cs1-lock-free" title="Freely accessible"><a rel="nofollow" class="external text" href="https://arxiv.org/abs/1810.05313">1810.05313</a></span>. <a href="/wiki/Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<a rel="nofollow" class="external text" href="https://doi.org/10.1016%2Fj.cam.2018.10.019">10.1016/j.cam.2018.10.019</a>. <a href="/wiki/S2CID_(identifier)" class="mw-redirect" title="S2CID (identifier)">S2CID</a>&#160;<a rel="nofollow" class="external text" href="https://api.semanticscholar.org/CorpusID:52983294">52983294</a>. <q>We report that these scrambled generators systematically fail Big Crush—specifically the linear-complexity and matrix-rank tests that detect linearity—when taking the 32 lowest-order bits in reverse order from each 64-bit word.</q></cite><span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&amp;rft.genre=article&amp;rft.jtitle=Computational+and+Applied+Mathematics&amp;rft.atitle=Xorshift1024%2A%2C+Xorshift1024%2B%2C+Xorshift128%2B+and+Xoroshiro128%2B+Fail+Statistical+Tests+for+Linearity&amp;rft.volume=350&amp;rft.pages=139-142&amp;rft.date=2019-04&amp;rft_id=info%3Aarxiv%2F1810.05313&amp;rft_id=https%3A%2F%2Fapi.semanticscholar.org%2FCorpusID%3A52983294%23id-name%3DS2CID&amp;rft_id=info%3Adoi%2F10.1016%2Fj.cam.2018.10.019&amp;rft.aulast=Lemire&amp;rft.aufirst=Daniel&amp;rft.au=O%E2%80%99Neill%2C+Melissa+E.&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3AXorshift" class="Z3988"></span></span>
</li>
<li id="cite_note-6"><span class="mw-cite-backlink"><b><a href="#cite_ref-6">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1133582631"><cite id="CITEREFLe_Floc&#39;h2011" class="citation web cs1">Le Floc'h, Fabien (12 January 2011). <a rel="nofollow" class="external text" href="https://chasethedevil.github.io/post/xorwow-lecuyer-testu01-results/">"XORWOW L'ecuyer TestU01 Results"</a>. <i>Chase The Devil (blog)</i><span class="reference-accessdate">. Retrieved <span class="nowrap">2017-11-02</span></span>.</cite><span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&amp;rft.genre=unknown&amp;rft.jtitle=Chase+The+Devil+%28blog%29&amp;rft.atitle=XORWOW+L%27ecuyer+TestU01+Results&amp;rft.date=2011-01-12&amp;rft.aulast=Le+Floc%27h&amp;rft.aufirst=Fabien&amp;rft_id=https%3A%2F%2Fchasethedevil.github.io%2Fpost%2Fxorwow-lecuyer-testu01-results%2F&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3AXorshift" class="Z3988"></span></span>
</li>
<li id="cite_note-7"><span class="mw-cite-backlink"><b><a href="#cite_ref-7">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1133582631"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://docs.nvidia.com/cuda/curand/testing.html">"cuRAND Testing"</a>. <a href="/wiki/Nvidia" title="Nvidia">Nvidia</a><span class="reference-accessdate">. Retrieved <span class="nowrap">2017-11-02</span></span>.</cite><span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&amp;rft.genre=unknown&amp;rft.btitle=cuRAND+Testing&amp;rft.pub=Nvidia&amp;rft_id=https%3A%2F%2Fdocs.nvidia.com%2Fcuda%2Fcurand%2Ftesting.html&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3AXorshift" class="Z3988"></span></span>
</li>
<li id="cite_note-vigna-8"><span class="mw-cite-backlink">^ <a href="#cite_ref-vigna_8-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-vigna_8-1"><sup><i><b>b</b></i></sup></a> <a href="#cite_ref-vigna_8-2"><sup><i><b>c</b></i></sup></a></span> <span class="reference-text">
<link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1133582631"><cite id="CITEREFVigna2016" class="citation journal cs1">Vigna, Sebastiano (July 2016). <a rel="nofollow" class="external text" href="http://vigna.di.unimi.it/ftp/papers/xorshift.pdf">"An experimental exploration of Marsaglia's xorshift generators, scrambled"</a> <span class="cs1-format">(PDF)</span>. <i>ACM Transactions on Mathematical Software</i>. <b>42</b> (4): 30. <a href="/wiki/ArXiv_(identifier)" class="mw-redirect" title="ArXiv (identifier)">arXiv</a>:<span class="cs1-lock-free" title="Freely accessible"><a rel="nofollow" class="external text" href="https://arxiv.org/abs/1402.6246">1402.6246</a></span>. <a href="/wiki/Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<a rel="nofollow" class="external text" href="https://doi.org/10.1145%2F2845077">10.1145/2845077</a>. <a href="/wiki/S2CID_(identifier)" class="mw-redirect" title="S2CID (identifier)">S2CID</a>&#160;<a rel="nofollow" class="external text" href="https://api.semanticscholar.org/CorpusID:13936073">13936073</a>.</cite><span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&amp;rft.genre=article&amp;rft.jtitle=ACM+Transactions+on+Mathematical+Software&amp;rft.atitle=An+experimental+exploration+of+Marsaglia%27s+xorshift+generators%2C+scrambled&amp;rft.volume=42&amp;rft.issue=4&amp;rft.pages=30&amp;rft.date=2016-07&amp;rft_id=info%3Aarxiv%2F1402.6246&amp;rft_id=https%3A%2F%2Fapi.semanticscholar.org%2FCorpusID%3A13936073%23id-name%3DS2CID&amp;rft_id=info%3Adoi%2F10.1145%2F2845077&amp;rft.aulast=Vigna&amp;rft.aufirst=Sebastiano&amp;rft_id=http%3A%2F%2Fvigna.di.unimi.it%2Fftp%2Fpapers%2Fxorshift.pdf&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3AXorshift" class="Z3988"></span> Proposes xorshift* generators, adding a final multiplication by a constant.</span>
</li>
<li id="cite_note-PCG-9"><span class="mw-cite-backlink">^ <a href="#cite_ref-PCG_9-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-PCG_9-1"><sup><i><b>b</b></i></sup></a></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1133582631"><cite id="CITEREFO&#39;Neill2014" class="citation techreport cs1">O'Neill, Melissa E. (5 September 2014). <a rel="nofollow" class="external text" href="http://www.pcg-random.org/pdf/hmc-cs-2014-0905.pdf"><i>PCG: A Family of Simple Fast Space-Efficient Statistically Good Algorithms for Random Number Generation</i></a> <span class="cs1-format">(PDF)</span> (Technical report). <a href="/wiki/Harvey_Mudd_College" title="Harvey Mudd College">Harvey Mudd College</a>. pp.&#160;68. HMC-CS-2014-0905.</cite><span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&amp;rft.genre=report&amp;rft.btitle=PCG%3A+A+Family+of+Simple+Fast+Space-Efficient+Statistically+Good+Algorithms+for+Random+Number+Generation&amp;rft.pages=6-8&amp;rft.pub=Harvey+Mudd+College&amp;rft.date=2014-09-05&amp;rft.aulast=O%27Neill&amp;rft.aufirst=Melissa+E.&amp;rft_id=http%3A%2F%2Fwww.pcg-random.org%2Fpdf%2Fhmc-cs-2014-0905.pdf&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3AXorshift" class="Z3988"></span></span>
</li>
<li id="cite_note-NR-10"><span class="mw-cite-backlink"><b><a href="#cite_ref-NR_10-0">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1133582631"><cite id="CITEREFPressTeukolskyVetterlingFlannery2007" class="citation book cs1"><a href="/wiki/William_H._Press" title="William H. Press">Press, WH</a>; <a href="/wiki/Saul_Teukolsky" title="Saul Teukolsky">Teukolsky, SA</a>; Vetterling, WT; Flannery, BP (2007). <a rel="nofollow" class="external text" href="http://apps.nrbook.com/empanel/index.html#pg=345">"Section 7.1.2.A. 64-bit Xorshift Method"</a>. <i>Numerical Recipes: The Art of Scientific Computing</i> (3rd&#160;ed.). New York: Cambridge University Press. <a href="/wiki/ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a>&#160;<a href="/wiki/Special:BookSources/978-0-521-88068-8" title="Special:BookSources/978-0-521-88068-8"><bdi>978-0-521-88068-8</bdi></a>.</cite><span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&amp;rft.genre=bookitem&amp;rft.atitle=Section+7.1.2.A.+64-bit+Xorshift+Method&amp;rft.btitle=Numerical+Recipes%3A+The+Art+of+Scientific+Computing&amp;rft.place=New+York&amp;rft.edition=3rd&amp;rft.pub=Cambridge+University+Press&amp;rft.date=2007&amp;rft.isbn=978-0-521-88068-8&amp;rft.aulast=Press&amp;rft.aufirst=WH&amp;rft.au=Teukolsky%2C+SA&amp;rft.au=Vetterling%2C+WT&amp;rft.au=Flannery%2C+BP&amp;rft_id=http%3A%2F%2Fapps.nrbook.com%2Fempanel%2Findex.html%23pg%3D345&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3AXorshift" class="Z3988"></span></span>
</li>
<li id="cite_note-shootout-11"><span class="mw-cite-backlink">^ <a href="#cite_ref-shootout_11-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-shootout_11-1"><sup><i><b>b</b></i></sup></a></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1133582631"><cite id="CITEREFVigna" class="citation web cs1">Vigna, Sebastiano. <a rel="nofollow" class="external text" href="http://prng.di.unimi.it">"xorshift*/xorshift+ generators and the PRNG shootout"</a><span class="reference-accessdate">. Retrieved <span class="nowrap">2014-10-25</span></span>.</cite><span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&amp;rft.genre=unknown&amp;rft.btitle=xorshift%2A%2Fxorshift%2B+generators+and+the+PRNG+shootout&amp;rft.aulast=Vigna&amp;rft.aufirst=Sebastiano&amp;rft_id=http%3A%2F%2Fprng.di.unimi.it&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3AXorshift" class="Z3988"></span></span>
</li>
<li id="cite_note-xsadd-12"><span class="mw-cite-backlink"><b><a href="#cite_ref-xsadd_12-0">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1133582631"><cite id="CITEREFSaitoMatsumoto2014" class="citation web cs1">Saito, Mutsuo; Matsumoto, Makoto (2014). <a rel="nofollow" class="external text" href="http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/XSADD/">"XORSHIFT-ADD (XSadd): A variant of XORSHIFT"</a><span class="reference-accessdate">. Retrieved <span class="nowrap">2014-10-25</span></span>.</cite><span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&amp;rft.genre=unknown&amp;rft.btitle=XORSHIFT-ADD+%28XSadd%29%3A+A+variant+of+XORSHIFT&amp;rft.date=2014&amp;rft.aulast=Saito&amp;rft.aufirst=Mutsuo&amp;rft.au=Matsumoto%2C+Makoto&amp;rft_id=http%3A%2F%2Fwww.math.sci.hiroshima-u.ac.jp%2F~m-mat%2FMT%2FXSADD%2F&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3AXorshift" class="Z3988"></span></span>
</li>
<li id="cite_note-vigna2-13"><span class="mw-cite-backlink">^ <a href="#cite_ref-vigna2_13-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-vigna2_13-1"><sup><i><b>b</b></i></sup></a></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1133582631"><cite id="CITEREFVigna2017" class="citation journal cs1">Vigna, Sebastiano (May 2017). <a rel="nofollow" class="external text" href="http://vigna.di.unimi.it/ftp/papers/xorshiftplus.pdf">"Further scramblings of Marsaglia's xorshift generators"</a> <span class="cs1-format">(PDF)</span>. <i>Journal of Computational and Applied Mathematics</i>. <b>315</b> (C): 175181. <a href="/wiki/ArXiv_(identifier)" class="mw-redirect" title="ArXiv (identifier)">arXiv</a>:<span class="cs1-lock-free" title="Freely accessible"><a rel="nofollow" class="external text" href="https://arxiv.org/abs/1404.0390">1404.0390</a></span>. <a href="/wiki/Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<a rel="nofollow" class="external text" href="https://doi.org/10.1016%2Fj.cam.2016.11.006">10.1016/j.cam.2016.11.006</a>. <a href="/wiki/S2CID_(identifier)" class="mw-redirect" title="S2CID (identifier)">S2CID</a>&#160;<a rel="nofollow" class="external text" href="https://api.semanticscholar.org/CorpusID:6876444">6876444</a>.</cite><span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&amp;rft.genre=article&amp;rft.jtitle=Journal+of+Computational+and+Applied+Mathematics&amp;rft.atitle=Further+scramblings+of+Marsaglia%27s+xorshift+generators&amp;rft.volume=315&amp;rft.issue=C&amp;rft.pages=175-181&amp;rft.date=2017-05&amp;rft_id=info%3Aarxiv%2F1404.0390&amp;rft_id=https%3A%2F%2Fapi.semanticscholar.org%2FCorpusID%3A6876444%23id-name%3DS2CID&amp;rft_id=info%3Adoi%2F10.1016%2Fj.cam.2016.11.006&amp;rft.aulast=Vigna&amp;rft.aufirst=Sebastiano&amp;rft_id=http%3A%2F%2Fvigna.di.unimi.it%2Fftp%2Fpapers%2Fxorshiftplus.pdf&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3AXorshift" class="Z3988"></span> Describes xorshift+ generators, a generalization of XSadd.</span>
</li>
<li id="cite_note-xoshiro-web-14"><span class="mw-cite-backlink"><b><a href="#cite_ref-xoshiro-web_14-0">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1133582631"><cite id="CITEREFVigna" class="citation web cs1">Vigna, Sebastiano. <a rel="nofollow" class="external text" href="http://xoroshiro.di.unimi.it">"xoshiro/xoroshiro generators and the PRNG shootout"</a><span class="reference-accessdate">. Retrieved <span class="nowrap">2019-07-07</span></span>.</cite><span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&amp;rft.genre=unknown&amp;rft.btitle=xoshiro%2Fxoroshiro+generators+and+the+PRNG+shootout&amp;rft.aulast=Vigna&amp;rft.aufirst=Sebastiano&amp;rft_id=http%3A%2F%2Fxoroshiro.di.unimi.it&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3AXorshift" class="Z3988"></span></span>
</li>
<li id="cite_note-xoshiro-paper-15"><span class="mw-cite-backlink">^ <a href="#cite_ref-xoshiro-paper_15-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-xoshiro-paper_15-1"><sup><i><b>b</b></i></sup></a></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1133582631"><cite id="CITEREFBlackmanVigna2018" class="citation journal cs1">Blackman, David; Vigna, Sebastiano (2018). "Scrambled Linear Pseudorandom Number Generators". <i>Data Structures and Algorithms</i>. <a href="/wiki/ArXiv_(identifier)" class="mw-redirect" title="ArXiv (identifier)">arXiv</a>:<span class="cs1-lock-free" title="Freely accessible"><a rel="nofollow" class="external text" href="https://arxiv.org/abs/1805.01407">1805.01407</a></span>.</cite><span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&amp;rft.genre=article&amp;rft.jtitle=Data+Structures+and+Algorithms&amp;rft.atitle=Scrambled+Linear+Pseudorandom+Number+Generators&amp;rft.date=2018&amp;rft_id=info%3Aarxiv%2F1805.01407&amp;rft.aulast=Blackman&amp;rft.aufirst=David&amp;rft.au=Vigna%2C+Sebastiano&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3AXorshift" class="Z3988"></span></span>
</li>
<li id="cite_note-xoshiro-16"><span class="mw-cite-backlink">^ <a href="#cite_ref-xoshiro_16-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-xoshiro_16-1"><sup><i><b>b</b></i></sup></a></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1133582631"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://prng.di.unimi.it">"xoshiro / xoroshiro generators and the PRNG shootout"</a><span class="reference-accessdate">. Retrieved <span class="nowrap">2023-09-07</span></span>.</cite><span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&amp;rft.genre=unknown&amp;rft.btitle=xoshiro+%2F+xoroshiro+generators+and+the+PRNG+shootout&amp;rft_id=https%3A%2F%2Fprng.di.unimi.it&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3AXorshift" class="Z3988"></span></span>
</li>
<li id="cite_note-initialization-17"><span class="mw-cite-backlink"><b><a href="#cite_ref-initialization_17-0">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1133582631"><cite id="CITEREFMatsumotoWadaKuramotoAshihara2007" class="citation journal cs1">Matsumoto, Makoto; Wada, Isaku; Kuramoto, Ai; Ashihara, Hyo (September 2007). "Common defects in initialization of pseudorandom number generators". <i>ACM Transactions on Modeling and Computer Simulation</i>. <b>17</b> (4): 15es. <a href="/wiki/Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<a rel="nofollow" class="external text" href="https://doi.org/10.1145%2F1276927.1276928">10.1145/1276927.1276928</a>. <a href="/wiki/S2CID_(identifier)" class="mw-redirect" title="S2CID (identifier)">S2CID</a>&#160;<a rel="nofollow" class="external text" href="https://api.semanticscholar.org/CorpusID:1721554">1721554</a>.</cite><span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&amp;rft.genre=article&amp;rft.jtitle=ACM+Transactions+on+Modeling+and+Computer+Simulation&amp;rft.atitle=Common+defects+in+initialization+of+pseudorandom+number+generators&amp;rft.volume=17&amp;rft.issue=4&amp;rft.pages=15-es&amp;rft.date=2007-09&amp;rft_id=info%3Adoi%2F10.1145%2F1276927.1276928&amp;rft_id=https%3A%2F%2Fapi.semanticscholar.org%2FCorpusID%3A1721554%23id-name%3DS2CID&amp;rft.aulast=Matsumoto&amp;rft.aufirst=Makoto&amp;rft.au=Wada%2C+Isaku&amp;rft.au=Kuramoto%2C+Ai&amp;rft.au=Ashihara%2C+Hyo&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3AXorshift" class="Z3988"></span></span>
</li>
</ol></div></div>
<h2><span class="mw-headline" id="Further_reading">Further reading</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Xorshift&amp;action=edit&amp;section=13" title="Edit section: Further reading"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></h2>
<ul><li><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1133582631"><cite class="citation journal cs1"><a href="/wiki/Richard_P._Brent" title="Richard P. Brent">Brent, Richard P.</a> (July 2006). <a rel="nofollow" class="external text" href="https://maths-people.anu.edu.au/~brent/pub/pub224.html">"Some long-period random number generators using shifts and xors"</a>. <i>ANZIAM Journal</i>. <b>48</b>: C188C202.</cite><span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&amp;rft.genre=article&amp;rft.jtitle=ANZIAM+Journal&amp;rft.atitle=Some+long-period+random+number+generators+using+shifts+and+xors&amp;rft.volume=48&amp;rft.pages=C188-C202&amp;rft.date=2006-07&amp;rft.aulast=Brent&amp;rft.aufirst=Richard+P.&amp;rft_id=https%3A%2F%2Fmaths-people.anu.edu.au%2F~brent%2Fpub%2Fpub224.html&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3AXorshift" class="Z3988"></span> Lists generators of various sizes with four shifts (two per feedback word).</li></ul>
<!--
NewPP limit report
Parsed by mw1350
Cached time: 20231125191829
Cache expiry: 1814400
Reduced expiry: false
Complications: [varyrevisionsha1, showtoc]
CPU time usage: 0.405 seconds
Real time usage: 0.579 seconds
Preprocessor visited node count: 4436/1000000
Postexpand include size: 39075/2097152 bytes
Template argument size: 2197/2097152 bytes
Highest expansion depth: 15/100
Expensive parser function count: 11/500
Unstrip recursion depth: 1/20
Unstrip postexpand size: 96692/5000000 bytes
Lua time usage: 0.187/10.000 seconds
Lua memory usage: 9303486/52428800 bytes
Number of Wikibase entities loaded: 0/400
-->
<!--
Transclusion expansion time report (%,ms,calls,template)
100.00% 491.091 1 -total
36.90% 181.212 2 Template:Reflist
25.00% 122.753 9 Template:Cite_journal
16.31% 80.112 8 Template:R
14.82% 72.794 9 Template:R/ref
11.76% 57.771 1 Template:Short_description
9.94% 48.796 9 Template:R/superscript
7.94% 38.989 1 Template:Val
6.75% 33.131 2 Template:Pagetype
6.07% 29.797 17 Template:R/where
-->
<!-- Saved in parser cache with key enwiki:pcache:idhash:17099722-0!canonical and timestamp 20231125191829 and revision id 1177332258. Rendering was triggered because: page-view
-->
</div><!--esi <esi:include src="/esitest-fa8a495983347898/content" /> --><noscript><img src="https://login.wikimedia.org/wiki/Special:CentralAutoLogin/start?type=1x1" alt="" width="1" height="1" style="border: none; position: absolute;"></noscript>
<div class="printfooter" data-nosnippet="">Retrieved from "<a dir="ltr" href="https://en.wikipedia.org/w/index.php?title=Xorshift&amp;oldid=1177332258">https://en.wikipedia.org/w/index.php?title=Xorshift&amp;oldid=1177332258</a>"</div></div>
<div id="catlinks" class="catlinks" data-mw="interface"><div id="mw-normal-catlinks" class="mw-normal-catlinks"><a href="/wiki/Help:Category" title="Help:Category">Category</a>: <ul><li><a href="/wiki/Category:Pseudorandom_number_generators" title="Category:Pseudorandom number generators">Pseudorandom number generators</a></li></ul></div><div id="mw-hidden-catlinks" class="mw-hidden-catlinks mw-hidden-cats-hidden">Hidden categories: <ul><li><a href="/wiki/Category:Articles_with_short_description" title="Category:Articles with short description">Articles with short description</a></li><li><a href="/wiki/Category:Short_description_is_different_from_Wikidata" title="Category:Short description is different from Wikidata">Short description is different from Wikidata</a></li><li><a href="/wiki/Category:Articles_with_example_C_code" title="Category:Articles with example C code">Articles with example C code</a></li></ul></div></div>
</div>
</main>
</div>
<div class="mw-footer-container">
<footer id="footer" class="mw-footer" role="contentinfo" >
<ul id="footer-info">
<li id="footer-info-lastmod"> This page was last edited on 27 September 2023, at 06:08<span class="anonymous-show">&#160;(UTC)</span>.</li>
<li id="footer-info-copyright">Text is available under the <a rel="license" href="//en.wikipedia.org/wiki/Wikipedia:Text_of_the_Creative_Commons_Attribution-ShareAlike_4.0_International_License">Creative Commons Attribution-ShareAlike License 4.0</a><a rel="license" href="//en.wikipedia.org/wiki/Wikipedia:Text_of_the_Creative_Commons_Attribution-ShareAlike_4.0_International_License" style="display:none;"></a>;
additional terms may apply. By using this site, you agree to the <a href="//foundation.wikimedia.org/wiki/Terms_of_Use">Terms of Use</a> and <a href="//foundation.wikimedia.org/wiki/Privacy_policy">Privacy Policy</a>. Wikipedia® is a registered trademark of the <a href="//www.wikimediafoundation.org/">Wikimedia Foundation, Inc.</a>, a non-profit organization.</li>
</ul>
<ul id="footer-places">
<li id="footer-places-privacy"><a href="https://foundation.wikimedia.org/wiki/Special:MyLanguage/Policy:Privacy_policy">Privacy policy</a></li>
<li id="footer-places-about"><a href="/wiki/Wikipedia:About">About Wikipedia</a></li>
<li id="footer-places-disclaimers"><a href="/wiki/Wikipedia:General_disclaimer">Disclaimers</a></li>
<li id="footer-places-contact"><a href="//en.wikipedia.org/wiki/Wikipedia:Contact_us">Contact Wikipedia</a></li>
<li id="footer-places-wm-codeofconduct"><a href="https://foundation.wikimedia.org/wiki/Special:MyLanguage/Policy:Universal_Code_of_Conduct">Code of Conduct</a></li>
<li id="footer-places-developers"><a href="https://developer.wikimedia.org">Developers</a></li>
<li id="footer-places-statslink"><a href="https://stats.wikimedia.org/#/en.wikipedia.org">Statistics</a></li>
<li id="footer-places-cookiestatement"><a href="https://foundation.wikimedia.org/wiki/Special:MyLanguage/Policy:Cookie_statement">Cookie statement</a></li>
<li id="footer-places-mobileview"><a href="//en.m.wikipedia.org/w/index.php?title=Xorshift&amp;mobileaction=toggle_view_mobile" class="noprint stopMobileRedirectToggle">Mobile view</a></li>
</ul>
<ul id="footer-icons" class="noprint">
<li id="footer-copyrightico"><a href="https://wikimediafoundation.org/"><img src="/static/images/footer/wikimedia-button.png" srcset="/static/images/footer/wikimedia-button-1.5x.png 1.5x, /static/images/footer/wikimedia-button-2x.png 2x" width="88" height="31" alt="Wikimedia Foundation" loading="lazy" /></a></li>
<li id="footer-poweredbyico"><a href="https://www.mediawiki.org/"><img src="/static/images/footer/poweredby_mediawiki_88x31.png" alt="Powered by MediaWiki" srcset="/static/images/footer/poweredby_mediawiki_132x47.png 1.5x, /static/images/footer/poweredby_mediawiki_176x62.png 2x" width="88" height="31" loading="lazy"></a></li>
</ul>
</footer>
</div>
</div>
</div>
<div class="vector-settings" id="p-dock-bottom">
<ul>
<li>
<button class="cdx-button cdx-button--icon-only vector-limited-width-toggle" id=""><span class="vector-icon mw-ui-icon-fullScreen mw-ui-icon-wikimedia-fullScreen"></span>
<span>Toggle limited content width</span>
</button>
</li>
</ul>
</div>
<script>(RLQ=window.RLQ||[]).push(function(){mw.config.set({"wgHostname":"mw1430","wgBackendResponseTime":138,"wgPageParseReport":{"limitreport":{"cputime":"0.405","walltime":"0.579","ppvisitednodes":{"value":4436,"limit":1000000},"postexpandincludesize":{"value":39075,"limit":2097152},"templateargumentsize":{"value":2197,"limit":2097152},"expansiondepth":{"value":15,"limit":100},"expensivefunctioncount":{"value":11,"limit":500},"unstrip-depth":{"value":1,"limit":20},"unstrip-size":{"value":96692,"limit":5000000},"entityaccesscount":{"value":0,"limit":400},"timingprofile":["100.00% 491.091 1 -total"," 36.90% 181.212 2 Template:Reflist"," 25.00% 122.753 9 Template:Cite_journal"," 16.31% 80.112 8 Template:R"," 14.82% 72.794 9 Template:R/ref"," 11.76% 57.771 1 Template:Short_description"," 9.94% 48.796 9 Template:R/superscript"," 7.94% 38.989 1 Template:Val"," 6.75% 33.131 2 Template:Pagetype"," 6.07% 29.797 17 Template:R/where"]},"scribunto":{"limitreport-timeusage":{"value":"0.187","limit":"10.000"},"limitreport-memusage":{"value":9303486,"limit":52428800}},"cachereport":{"origin":"mw1350","timestamp":"20231125191829","ttl":1814400,"transientcontent":false}}});});</script>
<script type="application/ld+json">{"@context":"https:\/\/schema.org","@type":"Article","name":"Xorshift","url":"https:\/\/en.wikipedia.org\/wiki\/Xorshift","sameAs":"http:\/\/www.wikidata.org\/entity\/Q2576999","mainEntity":"http:\/\/www.wikidata.org\/entity\/Q2576999","author":{"@type":"Organization","name":"Contributors to Wikimedia projects"},"publisher":{"@type":"Organization","name":"Wikimedia Foundation, Inc.","logo":{"@type":"ImageObject","url":"https:\/\/www.wikimedia.org\/static\/images\/wmf-hor-googpub.png"}},"datePublished":"2008-04-24T17:36:25Z","dateModified":"2023-09-27T06:08:45Z","image":"https:\/\/upload.wikimedia.org\/wikipedia\/commons\/e\/ee\/Xorshift.png","headline":"class of pseudorandom number generators which generate the next number in their sequence by repeatedly taking the xor of a number with a bit-shifted version of itself"}</script>
</body>
</html>