squiggle.c

Self-contained Monte Carlo estimation in C99
Log | Files | Refs | README

Box–Muller_transform (123674B)


      1 <!DOCTYPE html>
      2 <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">
      3 <head>
      4 <meta charset="UTF-8">
      5 <title>Box–Muller transform - Wikipedia</title>
      6 <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":["",""],
      7 "wgDefaultDateFormat":"dmy","wgMonthNames":["","January","February","March","April","May","June","July","August","September","October","November","December"],"wgRequestId":"42a7db9c-e419-4665-938e-75af5015b88d","wgCanonicalNamespace":"","wgCanonicalSpecialPageName":false,"wgNamespaceNumber":0,"wgPageName":"Box–Muller_transform","wgTitle":"Box–Muller transform","wgCurRevisionId":1184897234,"wgRevisionId":1184897234,"wgArticleId":60758,"wgIsArticle":true,"wgIsRedirect":false,"wgAction":"view","wgUserName":null,"wgUserGroups":["*"],"wgCategories":["Articles with short description","Short description matches Wikidata","Articles with example C++ code","Transforms","Non-uniform random numbers"],"wgPageViewLanguage":"en","wgPageContentLanguage":"en","wgPageContentModel":"wikitext","wgRelevantPageName":"Box–Muller_transform","wgRelevantArticleId":60758,"wgIsProbablyEditable":true,"wgRelevantPageIsProbablyEditable":true,"wgRestrictionEdit":[],"wgRestrictionMove":[],"wgNoticeProject":
      8 "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":10000,"wgULSCurrentAutonym":"English","wgCentralAuthMobileDomain":false,"wgEditSubmitButtonLabelPublish":true,"wgULSPosition":"interlanguage","wgULSisCompactLinksEnabled":true,"wgULSisLanguageSelectorEmpty":false,"wgWikibaseItemId":"Q895514","wgCheckUserClientHintsHeadersJsApi":["architecture","bitness","brands","fullVersionList","mobile","model","platform","platformVersion"],"GEHomepageSuggestedEditsEnableTopics":true,"wgGETopicsMatchModeEnabled":false,"wgGEStructuredTaskRejectionReasonTextInputEnabled":false,"wgGELevelingUpEnabledForUser":false};RLSTATE={"skins.vector.user.styles":
      9 "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.math.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","ext.scribunto.logs","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",
     10 "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>
     11 <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":"+\\"});
     12 }];});});</script>
     13 <link rel="stylesheet" href="/w/load.php?lang=en&amp;modules=codex-search-styles%7Cext.cite.styles%7Cext.math.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">
     14 <script async="" src="/w/load.php?lang=en&amp;modules=startup&amp;only=scripts&amp;raw=1&amp;skin=vector-2022"></script>
     15 <meta name="ResourceLoaderDynamicStyles" content="">
     16 <link rel="stylesheet" href="/w/load.php?lang=en&amp;modules=site.styles&amp;only=styles&amp;skin=vector-2022">
     17 <meta name="generator" content="MediaWiki 1.42.0-wmf.5">
     18 <meta name="referrer" content="origin">
     19 <meta name="referrer" content="origin-when-cross-origin">
     20 <meta name="robots" content="max-image-preview:standard">
     21 <meta name="format-detection" content="telephone=no">
     22 <meta property="og:image" content="https://upload.wikimedia.org/wikipedia/commons/thumb/1/1f/Box-Muller_transform_visualisation.svg/1200px-Box-Muller_transform_visualisation.svg.png">
     23 <meta property="og:image:width" content="1200">
     24 <meta property="og:image:height" content="1200">
     25 <meta property="og:image" content="https://upload.wikimedia.org/wikipedia/commons/thumb/1/1f/Box-Muller_transform_visualisation.svg/800px-Box-Muller_transform_visualisation.svg.png">
     26 <meta property="og:image:width" content="800">
     27 <meta property="og:image:height" content="800">
     28 <meta property="og:image" content="https://upload.wikimedia.org/wikipedia/commons/thumb/1/1f/Box-Muller_transform_visualisation.svg/640px-Box-Muller_transform_visualisation.svg.png">
     29 <meta property="og:image:width" content="640">
     30 <meta property="og:image:height" content="640">
     31 <meta name="viewport" content="width=1000">
     32 <meta property="og:title" content="Box–Muller transform - Wikipedia">
     33 <meta property="og:type" content="website">
     34 <link rel="preconnect" href="//upload.wikimedia.org">
     35 <link rel="alternate" media="only screen and (max-width: 720px)" href="//en.m.wikipedia.org/wiki/Box%E2%80%93Muller_transform">
     36 <link rel="alternate" type="application/x-wiki" title="Edit this page" href="/w/index.php?title=Box%E2%80%93Muller_transform&amp;action=edit">
     37 <link rel="apple-touch-icon" href="/static/apple-touch/wikipedia.png">
     38 <link rel="icon" href="/static/favicon/wikipedia.ico">
     39 <link rel="search" type="application/opensearchdescription+xml" href="/w/opensearch_desc.php" title="Wikipedia (en)">
     40 <link rel="EditURI" type="application/rsd+xml" href="//en.wikipedia.org/w/api.php?action=rsd">
     41 <link rel="canonical" href="https://en.wikipedia.org/wiki/Box%E2%80%93Muller_transform">
     42 <link rel="license" href="https://creativecommons.org/licenses/by-sa/4.0/deed.en">
     43 <link rel="alternate" type="application/atom+xml" title="Wikipedia Atom feed" href="/w/index.php?title=Special:RecentChanges&amp;feed=atom">
     44 <link rel="dns-prefetch" href="//meta.wikimedia.org" />
     45 <link rel="dns-prefetch" href="//login.wikimedia.org">
     46 </head>
     47 <body class="skin-vector skin-vector-search-vue mediawiki ltr sitedir-ltr mw-hide-empty-elt ns-0 ns-subject mw-editable page-Box–Muller_transform rootpage-Box–Muller_transform skin-vector-2022 action-view"><a class="mw-jump-link" href="#bodyContent">Jump to content</a>
     48 <div class="vector-header-container">
     49 	<header class="vector-header mw-header">
     50 		<div class="vector-header-start">
     51 			<nav class="vector-main-menu-landmark" aria-label="Site" role="navigation">
     52 				
     53 <div id="vector-main-menu-dropdown" class="vector-dropdown vector-main-menu-dropdown vector-button-flush-left vector-button-flush-right"  >
     54 	<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"  >
     55 	<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>
     56 
     57 <span class="vector-dropdown-label-text">Main menu</span>
     58 	</label>
     59 	<div class="vector-dropdown-content">
     60 
     61 
     62 				<div id="vector-main-menu-unpinned-container" class="vector-unpinned-container">
     63 		
     64 <div id="vector-main-menu" class="vector-main-menu vector-pinnable-element">
     65 	<div
     66 	class="vector-pinnable-header vector-main-menu-pinnable-header vector-pinnable-header-unpinned"
     67 	data-feature-name="main-menu-pinned"
     68 	data-pinnable-element-id="vector-main-menu"
     69 	data-pinned-container-id="vector-main-menu-pinned-container"
     70 	data-unpinned-container-id="vector-main-menu-unpinned-container"
     71 >
     72 	<div class="vector-pinnable-header-label">Main menu</div>
     73 	<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>
     74 	<button class="vector-pinnable-header-toggle-button vector-pinnable-header-unpin-button" data-event-name="pinnable-header.vector-main-menu.unpin">hide</button>
     75 </div>
     76 
     77 	
     78 <div id="p-navigation" class="vector-menu mw-portlet mw-portlet-navigation"  >
     79 	<div class="vector-menu-heading">
     80 		Navigation
     81 	</div>
     82 	<div class="vector-menu-content">
     83 		
     84 		<ul class="vector-menu-content-list">
     85 			
     86 			<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>
     87 		</ul>
     88 		
     89 	</div>
     90 </div>
     91 
     92 	
     93 	
     94 <div id="p-interaction" class="vector-menu mw-portlet mw-portlet-interaction"  >
     95 	<div class="vector-menu-heading">
     96 		Contribute
     97 	</div>
     98 	<div class="vector-menu-content">
     99 		
    100 		<ul class="vector-menu-content-list">
    101 			
    102 			<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>
    103 		</ul>
    104 		
    105 	</div>
    106 </div>
    107 
    108 	
    109 <div class="vector-main-menu-action vector-main-menu-action-lang-alert">
    110 	<div class="vector-main-menu-action-item">
    111 		<div class="vector-main-menu-action-heading vector-menu-heading">Languages</div>
    112 		<div class="vector-main-menu-action-content vector-menu-content">
    113 			<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>
    114 		</div>
    115 	</div>
    116 </div>
    117 
    118 </div>
    119 
    120 				</div>
    121 
    122 	</div>
    123 </div>
    124 
    125 		</nav>
    126 			
    127 <a href="/wiki/Main_Page" class="mw-logo">
    128 	<img class="mw-logo-icon" src="/static/images/icons/wikipedia.png" alt="" aria-hidden="true" height="50" width="50">
    129 	<span class="mw-logo-container">
    130 		<img class="mw-logo-wordmark" alt="Wikipedia" src="/static/images/mobile/copyright/wikipedia-wordmark-en.svg" style="width: 7.5em; height: 1.125em;">
    131 		<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;">
    132 	</span>
    133 </a>
    134 
    135 		</div>
    136 		<div class="vector-header-end">
    137 			
    138 <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">
    139 	<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>
    140 
    141 <span>Search</span>
    142 	</a>
    143 	<div class="vector-typeahead-search-container">
    144 		<div class="cdx-typeahead-search cdx-typeahead-search--show-thumbnail cdx-typeahead-search--auto-expand-width">
    145 			<form action="/w/index.php" id="searchform" class="cdx-search-input cdx-search-input--has-end-button">
    146 				<div id="simpleSearch" class="cdx-search-input__input-wrapper"  data-search-loc="header-moved">
    147 					<div class="cdx-text-input cdx-text-input--has-start-icon">
    148 						<input
    149 							class="cdx-text-input__input"
    150 							 type="search" name="search" placeholder="Search Wikipedia" aria-label="Search Wikipedia" autocapitalize="sentences" title="Search Wikipedia [f]" accesskey="f" id="searchInput"
    151 							>
    152 						<span class="cdx-text-input__icon cdx-text-input__start-icon"></span>
    153 					</div>
    154 					<input type="hidden" name="title" value="Special:Search">
    155 				</div>
    156 				<button class="cdx-button cdx-search-input__end-button">Search</button>
    157 			</form>
    158 		</div>
    159 	</div>
    160 </div>
    161 
    162 			<nav class="vector-user-links vector-user-links-wide" aria-label="Personal tools" role="navigation" >
    163 	<div class="vector-user-links-main">
    164 	
    165 <div id="p-vector-user-menu-preferences" class="vector-menu mw-portlet emptyPortlet"  >
    166 	<div class="vector-menu-content">
    167 		
    168 		<ul class="vector-menu-content-list">
    169 			
    170 			
    171 		</ul>
    172 		
    173 	</div>
    174 </div>
    175 
    176 	
    177 <div id="p-vector-user-menu-userpage" class="vector-menu mw-portlet emptyPortlet"  >
    178 	<div class="vector-menu-content">
    179 		
    180 		<ul class="vector-menu-content-list">
    181 			
    182 			
    183 		</ul>
    184 		
    185 	</div>
    186 </div>
    187 
    188 	
    189 <div id="p-vector-user-menu-notifications" class="vector-menu mw-portlet emptyPortlet"  >
    190 	<div class="vector-menu-content">
    191 		
    192 		<ul class="vector-menu-content-list">
    193 			
    194 			
    195 		</ul>
    196 		
    197 	</div>
    198 </div>
    199 
    200 	
    201 <div id="p-vector-user-menu-overflow" class="vector-menu mw-portlet"  >
    202 	<div class="vector-menu-content">
    203 		
    204 		<ul class="vector-menu-content-list">
    205 			<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=Box%E2%80%93Muller+transform" title="You are encouraged to create an account and log in; however, it is not mandatory" class=""><span>Create account</span></a>
    206 </li>
    207 <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=Box%E2%80%93Muller+transform" title="You&#039;re encouraged to log in; however, it&#039;s not mandatory. [o]" accesskey="o" class=""><span>Log in</span></a>
    208 </li>
    209 
    210 			
    211 		</ul>
    212 		
    213 	</div>
    214 </div>
    215 
    216 	</div>
    217 	
    218 <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" >
    219 	<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"  >
    220 	<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>
    221 
    222 <span class="vector-dropdown-label-text">Personal tools</span>
    223 	</label>
    224 	<div class="vector-dropdown-content">
    225 
    226 
    227 		
    228 <div id="p-personal" class="vector-menu mw-portlet mw-portlet-personal user-links-collapsible-item"  title="User menu" >
    229 	<div class="vector-menu-content">
    230 		
    231 		<ul class="vector-menu-content-list">
    232 			
    233 			<li id="pt-createaccount" class="user-links-collapsible-item mw-list-item"><a href="/w/index.php?title=Special:CreateAccount&amp;returnto=Box%E2%80%93Muller+transform" 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=Box%E2%80%93Muller+transform" 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>
    234 		</ul>
    235 		
    236 	</div>
    237 </div>
    238 
    239 <div id="p-user-menu-anon-editor" class="vector-menu mw-portlet mw-portlet-user-menu-anon-editor"  >
    240 	<div class="vector-menu-heading">
    241 		Pages for logged out editors <a href="/wiki/Help:Introduction" aria-label="Learn more about editing"><span>learn more</span></a>
    242 	</div>
    243 	<div class="vector-menu-content">
    244 		
    245 		<ul class="vector-menu-content-list">
    246 			
    247 			<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>
    248 		</ul>
    249 		
    250 	</div>
    251 </div>
    252 
    253 	
    254 	</div>
    255 </div>
    256 
    257 </nav>
    258 
    259 		</div>
    260 	</header>
    261 </div>
    262 <div class="mw-page-container">
    263 	<div class="mw-page-container-inner">
    264 		<div class="vector-sitenotice-container">
    265 			<div id="siteNotice"><!-- CentralNotice --></div>
    266 		</div>
    267 		
    268 			<div class="vector-main-menu-container">
    269 		<div id="mw-navigation">
    270 			<nav id="mw-panel" class="vector-main-menu-landmark" aria-label="Site" role="navigation">
    271 				<div id="vector-main-menu-pinned-container" class="vector-pinned-container">
    272 				
    273 				</div>
    274 		</nav>
    275 		</div>
    276 	</div>
    277 	<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">
    278 				<div id="vector-toc-pinned-container" class="vector-pinned-container">
    279 				<div id="vector-toc" class="vector-toc vector-pinnable-element">
    280 	<div
    281 	class="vector-pinnable-header vector-toc-pinnable-header vector-pinnable-header-pinned"
    282 	data-feature-name="toc-pinned"
    283 	data-pinnable-element-id="vector-toc"
    284 	
    285 	
    286 >
    287 	<h2 class="vector-pinnable-header-label">Contents</h2>
    288 	<button class="vector-pinnable-header-toggle-button vector-pinnable-header-pin-button" data-event-name="pinnable-header.vector-toc.pin">move to sidebar</button>
    289 	<button class="vector-pinnable-header-toggle-button vector-pinnable-header-unpin-button" data-event-name="pinnable-header.vector-toc.unpin">hide</button>
    290 </div>
    291 
    292 
    293 	<ul class="vector-toc-contents" id="mw-panel-toc-list">
    294 		<li id="toc-mw-content-text"
    295 			class="vector-toc-list-item vector-toc-level-1">
    296 			<a href="#" class="vector-toc-link">
    297 				<div class="vector-toc-text">(Top)</div>
    298 			</a>
    299 		</li>
    300 		<li id="toc-Basic_form"
    301 		class="vector-toc-list-item vector-toc-level-1 vector-toc-list-item-expanded">
    302 		<a class="vector-toc-link" href="#Basic_form">
    303 			<div class="vector-toc-text">
    304 			<span class="vector-toc-numb">1</span>Basic form</div>
    305 		</a>
    306 		
    307 		<ul id="toc-Basic_form-sublist" class="vector-toc-list">
    308 		</ul>
    309 	</li>
    310 	<li id="toc-Polar_form"
    311 		class="vector-toc-list-item vector-toc-level-1 vector-toc-list-item-expanded">
    312 		<a class="vector-toc-link" href="#Polar_form">
    313 			<div class="vector-toc-text">
    314 			<span class="vector-toc-numb">2</span>Polar form</div>
    315 		</a>
    316 		
    317 		<ul id="toc-Polar_form-sublist" class="vector-toc-list">
    318 		</ul>
    319 	</li>
    320 	<li id="toc-Contrasting_the_two_forms"
    321 		class="vector-toc-list-item vector-toc-level-1 vector-toc-list-item-expanded">
    322 		<a class="vector-toc-link" href="#Contrasting_the_two_forms">
    323 			<div class="vector-toc-text">
    324 			<span class="vector-toc-numb">3</span>Contrasting the two forms</div>
    325 		</a>
    326 		
    327 		<ul id="toc-Contrasting_the_two_forms-sublist" class="vector-toc-list">
    328 		</ul>
    329 	</li>
    330 	<li id="toc-Tails_truncation"
    331 		class="vector-toc-list-item vector-toc-level-1 vector-toc-list-item-expanded">
    332 		<a class="vector-toc-link" href="#Tails_truncation">
    333 			<div class="vector-toc-text">
    334 			<span class="vector-toc-numb">4</span>Tails truncation</div>
    335 		</a>
    336 		
    337 		<ul id="toc-Tails_truncation-sublist" class="vector-toc-list">
    338 		</ul>
    339 	</li>
    340 	<li id="toc-Implementation"
    341 		class="vector-toc-list-item vector-toc-level-1 vector-toc-list-item-expanded">
    342 		<a class="vector-toc-link" href="#Implementation">
    343 			<div class="vector-toc-text">
    344 			<span class="vector-toc-numb">5</span>Implementation</div>
    345 		</a>
    346 		
    347 		<ul id="toc-Implementation-sublist" class="vector-toc-list">
    348 		</ul>
    349 	</li>
    350 	<li id="toc-See_also"
    351 		class="vector-toc-list-item vector-toc-level-1 vector-toc-list-item-expanded">
    352 		<a class="vector-toc-link" href="#See_also">
    353 			<div class="vector-toc-text">
    354 			<span class="vector-toc-numb">6</span>See also</div>
    355 		</a>
    356 		
    357 		<ul id="toc-See_also-sublist" class="vector-toc-list">
    358 		</ul>
    359 	</li>
    360 	<li id="toc-References"
    361 		class="vector-toc-list-item vector-toc-level-1 vector-toc-list-item-expanded">
    362 		<a class="vector-toc-link" href="#References">
    363 			<div class="vector-toc-text">
    364 			<span class="vector-toc-numb">7</span>References</div>
    365 		</a>
    366 		
    367 		<ul id="toc-References-sublist" class="vector-toc-list">
    368 		</ul>
    369 	</li>
    370 	<li id="toc-External_links"
    371 		class="vector-toc-list-item vector-toc-level-1 vector-toc-list-item-expanded">
    372 		<a class="vector-toc-link" href="#External_links">
    373 			<div class="vector-toc-text">
    374 			<span class="vector-toc-numb">8</span>External links</div>
    375 		</a>
    376 		
    377 		<ul id="toc-External_links-sublist" class="vector-toc-list">
    378 		</ul>
    379 	</li>
    380 </ul>
    381 </div>
    382 
    383 				</div>
    384 	</nav>
    385 		
    386 		<div class="mw-content-container">
    387 			<main id="content" class="mw-body" role="main">
    388 				<header class="mw-body-header vector-page-titlebar">
    389 					<nav role="navigation" aria-label="Contents" class="vector-toc-landmark">
    390 						
    391 <div id="vector-page-titlebar-toc" class="vector-dropdown vector-page-titlebar-toc vector-button-flush-left"  >
    392 	<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"  >
    393 	<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>
    394 
    395 <span class="vector-dropdown-label-text">Toggle the table of contents</span>
    396 	</label>
    397 	<div class="vector-dropdown-content">
    398 
    399 
    400 							<div id="vector-page-titlebar-toc-unpinned-container" class="vector-unpinned-container">
    401 			</div>
    402 		
    403 	</div>
    404 </div>
    405 
    406 					</nav>
    407 					<h1 id="firstHeading" class="firstHeading mw-first-heading"><span class="mw-page-title-main">Box–Muller transform</span></h1>
    408 							
    409 <div id="p-lang-btn" class="vector-dropdown mw-portlet mw-portlet-lang"  >
    410 	<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 13 languages"   >
    411 	<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-13" aria-hidden="true"  ><span class="vector-icon mw-ui-icon-language-progressive mw-ui-icon-wikimedia-language-progressive"></span>
    412 
    413 <span class="vector-dropdown-label-text">13 languages</span>
    414 	</label>
    415 	<div class="vector-dropdown-content">
    416 
    417 		<div class="vector-menu-content">
    418 			
    419 			<ul class="vector-menu-content-list">
    420 				
    421 				<li class="interlanguage-link interwiki-ca mw-list-item"><a href="https://ca.wikipedia.org/wiki/Transformada_de_Box-Mulle" title="Transformada de Box-Mulle – Catalan" lang="ca" hreflang="ca" class="interlanguage-link-target"><span>Català</span></a></li><li class="interlanguage-link interwiki-de mw-list-item"><a href="https://de.wikipedia.org/wiki/Box-Muller-Methode" title="Box-Muller-Methode – German" lang="de" hreflang="de" class="interlanguage-link-target"><span>Deutsch</span></a></li><li class="interlanguage-link interwiki-es mw-list-item"><a href="https://es.wikipedia.org/wiki/M%C3%A9todo_de_Box-Muller" title="Método de Box-Muller – Spanish" lang="es" hreflang="es" class="interlanguage-link-target"><span>Español</span></a></li><li class="interlanguage-link interwiki-fa mw-list-item"><a href="https://fa.wikipedia.org/wiki/%D8%AA%D8%A8%D8%AF%DB%8C%D9%84_%D8%A8%D8%A7%DA%A9%D8%B3-%D9%85%D9%88%D9%84%D8%B1" title="تبدیل باکس-مولر – Persian" lang="fa" hreflang="fa" class="interlanguage-link-target"><span>فارسی</span></a></li><li class="interlanguage-link interwiki-fr mw-list-item"><a href="https://fr.wikipedia.org/wiki/M%C3%A9thode_de_Box-Muller" title="Méthode de Box-Muller – French" lang="fr" hreflang="fr" class="interlanguage-link-target"><span>Français</span></a></li><li class="interlanguage-link interwiki-it mw-list-item"><a href="https://it.wikipedia.org/wiki/Trasformazione_di_Box-Muller" title="Trasformazione di Box-Muller – Italian" lang="it" hreflang="it" class="interlanguage-link-target"><span>Italiano</span></a></li><li class="interlanguage-link interwiki-he mw-list-item"><a href="https://he.wikipedia.org/wiki/%D7%98%D7%A8%D7%A0%D7%A1%D7%A4%D7%95%D7%A8%D7%9E%D7%A6%D7%99%D7%99%D7%AA_%D7%91%D7%95%D7%A7%D7%A1-%D7%9E%D7%99%D7%9C%D7%A8" title="טרנספורמציית בוקס-מילר – Hebrew" lang="he" hreflang="he" class="interlanguage-link-target"><span>עברית</span></a></li><li class="interlanguage-link interwiki-ja mw-list-item"><a href="https://ja.wikipedia.org/wiki/%E3%83%9C%E3%83%83%E3%82%AF%E3%82%B9%EF%BC%9D%E3%83%9F%E3%83%A5%E3%83%A9%E3%83%BC%E6%B3%95" title="ボックス=ミュラー法 – Japanese" lang="ja" hreflang="ja" class="interlanguage-link-target"><span>日本語</span></a></li><li class="interlanguage-link interwiki-pl mw-list-item"><a href="https://pl.wikipedia.org/wiki/Transformacja_Boxa-Mullera" title="Transformacja Boxa-Mullera – Polish" lang="pl" hreflang="pl" class="interlanguage-link-target"><span>Polski</span></a></li><li class="interlanguage-link interwiki-pt mw-list-item"><a href="https://pt.wikipedia.org/wiki/Transforma%C3%A7%C3%A3o_de_Box-Muller" title="Transformação de Box-Muller – 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/%D0%9F%D1%80%D0%B5%D0%BE%D0%B1%D1%80%D0%B0%D0%B7%D0%BE%D0%B2%D0%B0%D0%BD%D0%B8%D0%B5_%D0%91%D0%BE%D0%BA%D1%81%D0%B0_%E2%80%94_%D0%9C%D1%8E%D0%BB%D0%BB%D0%B5%D1%80%D0%B0" title="Преобразование Бокса — Мюллера – Russian" lang="ru" hreflang="ru" class="interlanguage-link-target"><span>Русский</span></a></li><li class="interlanguage-link interwiki-su mw-list-item"><a href="https://su.wikipedia.org/wiki/Transformasi_Box-Muller" title="Transformasi Box-Muller – Sundanese" lang="su" hreflang="su" class="interlanguage-link-target"><span>Sunda</span></a></li><li class="interlanguage-link interwiki-uk mw-list-item"><a href="https://uk.wikipedia.org/wiki/%D0%9F%D0%B5%D1%80%D0%B5%D1%82%D0%B2%D0%BE%D1%80%D0%B5%D0%BD%D0%BD%D1%8F_%D0%91%D0%BE%D0%BA%D1%81%D0%B0-%D0%9C%D1%8E%D0%BB%D0%BB%D0%B5%D1%80%D0%B0" title="Перетворення Бокса-Мюллера – Ukrainian" lang="uk" hreflang="uk" class="interlanguage-link-target"><span>Українська</span></a></li>
    422 			</ul>
    423 			<div class="after-portlet after-portlet-lang"><span class="wb-langlinks-edit wb-langlinks-link"><a href="https://www.wikidata.org/wiki/Special:EntityPage/Q895514#sitelinks-wikipedia" title="Edit interlanguage links" class="wbc-editpage">Edit links</a></span></div>
    424 		</div>
    425 
    426 	</div>
    427 </div>
    428 </header>
    429 				<div class="vector-page-toolbar">
    430 					<div class="vector-page-toolbar-container">
    431 						<div id="left-navigation">
    432 							<nav aria-label="Namespaces">
    433 								
    434 <div id="p-associated-pages" class="vector-menu vector-menu-tabs mw-portlet mw-portlet-associated-pages"  >
    435 	<div class="vector-menu-content">
    436 		
    437 		<ul class="vector-menu-content-list">
    438 			
    439 			<li id="ca-nstab-main" class="selected vector-tab-noicon mw-list-item"><a href="/wiki/Box%E2%80%93Muller_transform" 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:Box%E2%80%93Muller_transform" rel="discussion" title="Discuss improvements to the content page [t]" accesskey="t"><span>Talk</span></a></li>
    440 		</ul>
    441 		
    442 	</div>
    443 </div>
    444 
    445 								
    446 <div id="p-variants" class="vector-dropdown emptyPortlet"  >
    447 	<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"   >
    448 	<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>
    449 	</label>
    450 	<div class="vector-dropdown-content">
    451 
    452 
    453 					
    454 <div id="p-variants" class="vector-menu mw-portlet mw-portlet-variants emptyPortlet"  >
    455 	<div class="vector-menu-content">
    456 		
    457 		<ul class="vector-menu-content-list">
    458 			
    459 			
    460 		</ul>
    461 		
    462 	</div>
    463 </div>
    464 
    465 				
    466 	</div>
    467 </div>
    468 
    469 							</nav>
    470 						</div>
    471 						<div id="right-navigation" class="vector-collapsible">
    472 							<nav aria-label="Views">
    473 								
    474 <div id="p-views" class="vector-menu vector-menu-tabs mw-portlet mw-portlet-views"  >
    475 	<div class="vector-menu-content">
    476 		
    477 		<ul class="vector-menu-content-list">
    478 			
    479 			<li id="ca-view" class="selected vector-tab-noicon mw-list-item"><a href="/wiki/Box%E2%80%93Muller_transform"><span>Read</span></a></li><li id="ca-edit" class="vector-tab-noicon mw-list-item"><a href="/w/index.php?title=Box%E2%80%93Muller_transform&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=Box%E2%80%93Muller_transform&amp;action=history" title="Past revisions of this page [h]" accesskey="h"><span>View history</span></a></li>
    480 		</ul>
    481 		
    482 	</div>
    483 </div>
    484 
    485 							</nav>
    486 				
    487 							<nav class="vector-page-tools-landmark" aria-label="Page tools">
    488 								
    489 <div id="vector-page-tools-dropdown" class="vector-dropdown vector-page-tools-dropdown"  >
    490 	<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"  >
    491 	<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>
    492 	</label>
    493 	<div class="vector-dropdown-content">
    494 
    495 
    496 									<div id="vector-page-tools-unpinned-container" class="vector-unpinned-container">
    497 						
    498 <div id="vector-page-tools" class="vector-page-tools vector-pinnable-element">
    499 	<div
    500 	class="vector-pinnable-header vector-page-tools-pinnable-header vector-pinnable-header-unpinned"
    501 	data-feature-name="page-tools-pinned"
    502 	data-pinnable-element-id="vector-page-tools"
    503 	data-pinned-container-id="vector-page-tools-pinned-container"
    504 	data-unpinned-container-id="vector-page-tools-unpinned-container"
    505 >
    506 	<div class="vector-pinnable-header-label">Tools</div>
    507 	<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>
    508 	<button class="vector-pinnable-header-toggle-button vector-pinnable-header-unpin-button" data-event-name="pinnable-header.vector-page-tools.unpin">hide</button>
    509 </div>
    510 
    511 	
    512 <div id="p-cactions" class="vector-menu mw-portlet mw-portlet-cactions emptyPortlet vector-has-collapsible-items"  title="More options" >
    513 	<div class="vector-menu-heading">
    514 		Actions
    515 	</div>
    516 	<div class="vector-menu-content">
    517 		
    518 		<ul class="vector-menu-content-list">
    519 			
    520 			<li id="ca-more-view" class="selected vector-more-collapsible-item mw-list-item"><a href="/wiki/Box%E2%80%93Muller_transform"><span>Read</span></a></li><li id="ca-more-edit" class="vector-more-collapsible-item mw-list-item"><a href="/w/index.php?title=Box%E2%80%93Muller_transform&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=Box%E2%80%93Muller_transform&amp;action=history"><span>View history</span></a></li>
    521 		</ul>
    522 		
    523 	</div>
    524 </div>
    525 
    526 <div id="p-tb" class="vector-menu mw-portlet mw-portlet-tb"  >
    527 	<div class="vector-menu-heading">
    528 		General
    529 	</div>
    530 	<div class="vector-menu-content">
    531 		
    532 		<ul class="vector-menu-content-list">
    533 			
    534 			<li id="t-whatlinkshere" class="mw-list-item"><a href="/wiki/Special:WhatLinksHere/Box%E2%80%93Muller_transform" 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/Box%E2%80%93Muller_transform" 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=Box%E2%80%93Muller_transform&amp;oldid=1184897234" 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=Box%E2%80%93Muller_transform&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=Box%E2%80%93Muller_transform&amp;id=1184897234&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%2FBox%25E2%2580%2593Muller_transform"><span>Get shortened URL</span></a></li><li id="t-wikibase" class="mw-list-item"><a href="https://www.wikidata.org/wiki/Special:EntityPage/Q895514" title="Structured data on this page hosted by Wikidata [g]" accesskey="g"><span>Wikidata item</span></a></li>
    535 		</ul>
    536 		
    537 	</div>
    538 </div>
    539 
    540 <div id="p-coll-print_export" class="vector-menu mw-portlet mw-portlet-coll-print_export"  >
    541 	<div class="vector-menu-heading">
    542 		Print/export
    543 	</div>
    544 	<div class="vector-menu-content">
    545 		
    546 		<ul class="vector-menu-content-list">
    547 			
    548 			<li id="coll-download-as-rl" class="mw-list-item"><a href="/w/index.php?title=Special:DownloadAsPdf&amp;page=Box%E2%80%93Muller_transform&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=Box%E2%80%93Muller_transform&amp;printable=yes" title="Printable version of this page [p]" accesskey="p"><span>Printable version</span></a></li>
    549 		</ul>
    550 		
    551 	</div>
    552 </div>
    553 
    554 </div>
    555 
    556 									</div>
    557 				
    558 	</div>
    559 </div>
    560 
    561 							</nav>
    562 						</div>
    563 					</div>
    564 				</div>
    565 				<div class="vector-column-end">
    566 					<nav class="vector-page-tools-landmark vector-sticky-pinned-container" aria-label="Page tools">
    567 						<div id="vector-page-tools-pinned-container" class="vector-pinned-container">
    568 			
    569 						</div>
    570 	</nav>
    571 				</div>
    572 				<div id="bodyContent" class="vector-body" aria-labelledby="firstHeading" data-mw-ve-target-container>
    573 					<div class="vector-body-before-content">
    574 							<div class="mw-indicators">
    575 		</div>
    576 
    577 						<div id="siteSub" class="noprint">From Wikipedia, the free encyclopedia</div>
    578 					</div>
    579 					<div id="contentSub"><div id="mw-content-subtitle"></div></div>
    580 					
    581 					
    582 					<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">Statistical transform</div>
    583 <figure typeof="mw:File/Thumb"><a href="/wiki/File:Box-Muller_transform_visualisation.svg" class="mw-file-description"><img src="//upload.wikimedia.org/wikipedia/commons/thumb/1/1f/Box-Muller_transform_visualisation.svg/300px-Box-Muller_transform_visualisation.svg.png" decoding="async" width="300" height="300" class="mw-file-element" srcset="//upload.wikimedia.org/wikipedia/commons/thumb/1/1f/Box-Muller_transform_visualisation.svg/450px-Box-Muller_transform_visualisation.svg.png 1.5x, //upload.wikimedia.org/wikipedia/commons/thumb/1/1f/Box-Muller_transform_visualisation.svg/600px-Box-Muller_transform_visualisation.svg.png 2x" data-file-width="512" data-file-height="512" /></a><figcaption>Visualisation of the Box–Muller transform — the coloured points in the unit square (u1, u2), drawn as circles, are mapped to a 2D Gaussian (z0, z1), drawn as crosses. The plots at the margins are the probability distribution functions of z0 and z1. z0 and z1 are unbounded; they appear to be in [-2.5,2.5] due to the choice of the illustrated points. In <a class="external text" href="https://upload.wikimedia.org/wikipedia/commons/1/1f/Box-Muller_transform_visualisation.svg">the SVG file</a>, hover over a point to highlight it and its corresponding point.</figcaption></figure>
    584 <p>The <b>Box–Muller transform</b>, by <a href="/wiki/George_E._P._Box" title="George E. P. Box">George Edward Pelham Box</a> and <a href="/wiki/Mervin_Edgar_Muller" class="mw-redirect" title="Mervin Edgar Muller">Mervin Edgar Muller</a>,<sup id="cite_ref-1" class="reference"><a href="#cite_note-1">&#91;1&#93;</a></sup> is a <a href="/wiki/Random_number_sampling" class="mw-redirect" title="Random number sampling">random number sampling</a> method for generating pairs of <a href="/wiki/Statistical_independence" class="mw-redirect" title="Statistical independence">independent</a>, standard, <a href="/wiki/Normal_distribution" title="Normal distribution">normally distributed</a> (zero <a href="/wiki/Expected_value" title="Expected value">expectation</a>, unit <a href="/wiki/Variance" title="Variance">variance</a>) random numbers, given a source of <a href="/wiki/Uniform_distribution_(continuous)" class="mw-redirect" title="Uniform distribution (continuous)">uniformly distributed</a> random numbers. The method was in fact first mentioned explicitly by <a href="/wiki/Raymond_Paley" title="Raymond Paley">Raymond E. A. C. Paley</a> and <a href="/wiki/Norbert_Wiener" title="Norbert Wiener">Norbert Wiener</a> in 1934.<sup id="cite_ref-2" class="reference"><a href="#cite_note-2">&#91;2&#93;</a></sup>
    585 </p><p>The Box–Muller transform is commonly expressed in two forms. The basic form as given by Box and Muller takes two samples from the uniform distribution on the interval [0,&#160;1] and maps them to two standard, normally distributed samples.  The polar form takes two samples from a different interval, [−1,&#160;+1], and maps them to two normally distributed samples without the use of sine or cosine functions.
    586 </p><p>The Box–Muller transform was developed as a more computationally efficient alternative to the <a href="/wiki/Inverse_transform_sampling_method" class="mw-redirect" title="Inverse transform sampling method">inverse transform sampling method</a>.<sup id="cite_ref-3" class="reference"><a href="#cite_note-3">&#91;3&#93;</a></sup> The <a href="/wiki/Ziggurat_algorithm" title="Ziggurat algorithm">ziggurat algorithm</a> gives a more efficient method for scalar processors (e.g. old CPUs), while the Box–Muller transform is superior for processors with vector units (e.g. GPUs or modern CPUs).<sup id="cite_ref-4" class="reference"><a href="#cite_note-4">&#91;4&#93;</a></sup>
    587 </p>
    588 <meta property="mw:PageProp/toc" />
    589 <h2><span class="mw-headline" id="Basic_form">Basic form</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Box%E2%80%93Muller_transform&amp;action=edit&amp;section=1" title="Edit section: Basic form"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></h2>
    590 <p>Suppose <i>U</i><sub>1</sub> and <i>U</i><sub>2</sub> are independent samples chosen from the uniform distribution on the <a href="/wiki/Interval_(mathematics)" title="Interval (mathematics)">unit interval</a> (0,&#160;1). Let
    591 </p>
    592 <dl><dd><span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML"  alttext="{\displaystyle Z_{0}=R\cos(\Theta )={\sqrt {-2\ln U_{1}}}\cos(2\pi U_{2})\,}">
    593   <semantics>
    594     <mrow class="MJX-TeXAtom-ORD">
    595       <mstyle displaystyle="true" scriptlevel="0">
    596         <msub>
    597           <mi>Z</mi>
    598           <mrow class="MJX-TeXAtom-ORD">
    599             <mn>0</mn>
    600           </mrow>
    601         </msub>
    602         <mo>=</mo>
    603         <mi>R</mi>
    604         <mi>cos</mi>
    605         <mo>&#x2061;<!-- ⁡ --></mo>
    606         <mo stretchy="false">(</mo>
    607         <mi mathvariant="normal">&#x0398;<!-- Θ --></mi>
    608         <mo stretchy="false">)</mo>
    609         <mo>=</mo>
    610         <mrow class="MJX-TeXAtom-ORD">
    611           <msqrt>
    612             <mo>&#x2212;<!-- − --></mo>
    613             <mn>2</mn>
    614             <mi>ln</mi>
    615             <mo>&#x2061;<!-- ⁡ --></mo>
    616             <msub>
    617               <mi>U</mi>
    618               <mrow class="MJX-TeXAtom-ORD">
    619                 <mn>1</mn>
    620               </mrow>
    621             </msub>
    622           </msqrt>
    623         </mrow>
    624         <mi>cos</mi>
    625         <mo>&#x2061;<!-- ⁡ --></mo>
    626         <mo stretchy="false">(</mo>
    627         <mn>2</mn>
    628         <mi>&#x03C0;<!-- π --></mi>
    629         <msub>
    630           <mi>U</mi>
    631           <mrow class="MJX-TeXAtom-ORD">
    632             <mn>2</mn>
    633           </mrow>
    634         </msub>
    635         <mo stretchy="false">)</mo>
    636         <mspace width="thinmathspace" />
    637       </mstyle>
    638     </mrow>
    639     <annotation encoding="application/x-tex">{\displaystyle Z_{0}=R\cos(\Theta )={\sqrt {-2\ln U_{1}}}\cos(2\pi U_{2})\,}</annotation>
    640   </semantics>
    641 </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/46e09d833afb2466f517e90dbc0e363cb0bcdf8a" class="mwe-math-fallback-image-inline mw-invert" aria-hidden="true" style="vertical-align: -1.005ex; width:39.199ex; height:3.343ex;" alt="Z_0 = R \cos(\Theta) =\sqrt{-2 \ln U_1} \cos(2 \pi U_2)\,"></span></dd></dl>
    642 <p>and
    643 </p>
    644 <dl><dd><span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML"  alttext="{\displaystyle Z_{1}=R\sin(\Theta )={\sqrt {-2\ln U_{1}}}\sin(2\pi U_{2}).\,}">
    645   <semantics>
    646     <mrow class="MJX-TeXAtom-ORD">
    647       <mstyle displaystyle="true" scriptlevel="0">
    648         <msub>
    649           <mi>Z</mi>
    650           <mrow class="MJX-TeXAtom-ORD">
    651             <mn>1</mn>
    652           </mrow>
    653         </msub>
    654         <mo>=</mo>
    655         <mi>R</mi>
    656         <mi>sin</mi>
    657         <mo>&#x2061;<!-- ⁡ --></mo>
    658         <mo stretchy="false">(</mo>
    659         <mi mathvariant="normal">&#x0398;<!-- Θ --></mi>
    660         <mo stretchy="false">)</mo>
    661         <mo>=</mo>
    662         <mrow class="MJX-TeXAtom-ORD">
    663           <msqrt>
    664             <mo>&#x2212;<!-- − --></mo>
    665             <mn>2</mn>
    666             <mi>ln</mi>
    667             <mo>&#x2061;<!-- ⁡ --></mo>
    668             <msub>
    669               <mi>U</mi>
    670               <mrow class="MJX-TeXAtom-ORD">
    671                 <mn>1</mn>
    672               </mrow>
    673             </msub>
    674           </msqrt>
    675         </mrow>
    676         <mi>sin</mi>
    677         <mo>&#x2061;<!-- ⁡ --></mo>
    678         <mo stretchy="false">(</mo>
    679         <mn>2</mn>
    680         <mi>&#x03C0;<!-- π --></mi>
    681         <msub>
    682           <mi>U</mi>
    683           <mrow class="MJX-TeXAtom-ORD">
    684             <mn>2</mn>
    685           </mrow>
    686         </msub>
    687         <mo stretchy="false">)</mo>
    688         <mo>.</mo>
    689         <mspace width="thinmathspace" />
    690       </mstyle>
    691     </mrow>
    692     <annotation encoding="application/x-tex">{\displaystyle Z_{1}=R\sin(\Theta )={\sqrt {-2\ln U_{1}}}\sin(2\pi U_{2}).\,}</annotation>
    693   </semantics>
    694 </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/5c1ef74f02625a0a670e7c7668e990d8446f8fde" class="mwe-math-fallback-image-inline mw-invert" aria-hidden="true" style="vertical-align: -1.005ex; width:39.335ex; height:3.343ex;" alt="Z_1 = R \sin(\Theta) = \sqrt{-2 \ln U_1} \sin(2 \pi U_2).\,"></span></dd></dl>
    695 <p>Then <i>Z</i><sub>0</sub> and <i>Z</i><sub>1</sub> are <a href="/wiki/Statistical_independence" class="mw-redirect" title="Statistical independence">independent</a> random variables with a <a href="/wiki/Standard_normal_distribution" class="mw-redirect" title="Standard normal distribution">standard normal distribution</a>.
    696 </p><p>The derivation<sup id="cite_ref-5" class="reference"><a href="#cite_note-5">&#91;5&#93;</a></sup> is based on a property of a two-dimensional <a href="/wiki/Cartesian_coordinate_system" title="Cartesian coordinate system">Cartesian system</a>, where X and Y coordinates are described by two independent and normally distributed random variables, the random variables for <i>R</i><sup>2</sup> and Θ (shown above) in the corresponding polar coordinates are also independent and can be expressed as
    697 </p>
    698 <dl><dd><span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML"  alttext="{\displaystyle R^{2}=-2\cdot \ln U_{1}\,}">
    699   <semantics>
    700     <mrow class="MJX-TeXAtom-ORD">
    701       <mstyle displaystyle="true" scriptlevel="0">
    702         <msup>
    703           <mi>R</mi>
    704           <mrow class="MJX-TeXAtom-ORD">
    705             <mn>2</mn>
    706           </mrow>
    707         </msup>
    708         <mo>=</mo>
    709         <mo>&#x2212;<!-- − --></mo>
    710         <mn>2</mn>
    711         <mo>&#x22C5;<!-- ⋅ --></mo>
    712         <mi>ln</mi>
    713         <mo>&#x2061;<!-- ⁡ --></mo>
    714         <msub>
    715           <mi>U</mi>
    716           <mrow class="MJX-TeXAtom-ORD">
    717             <mn>1</mn>
    718           </mrow>
    719         </msub>
    720         <mspace width="thinmathspace" />
    721       </mstyle>
    722     </mrow>
    723     <annotation encoding="application/x-tex">{\displaystyle R^{2}=-2\cdot \ln U_{1}\,}</annotation>
    724   </semantics>
    725 </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/702928cf2d25505446185f796a9dcfa0f0d5034b" class="mwe-math-fallback-image-inline mw-invert" aria-hidden="true" style="vertical-align: -0.671ex; width:15.922ex; height:3.009ex;" alt="R^2 = -2\cdot\ln U_1\,"></span></dd></dl>
    726 <p>and
    727 </p>
    728 <dl><dd><span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML"  alttext="{\displaystyle \Theta =2\pi U_{2}.\,}">
    729   <semantics>
    730     <mrow class="MJX-TeXAtom-ORD">
    731       <mstyle displaystyle="true" scriptlevel="0">
    732         <mi mathvariant="normal">&#x0398;<!-- Θ --></mi>
    733         <mo>=</mo>
    734         <mn>2</mn>
    735         <mi>&#x03C0;<!-- π --></mi>
    736         <msub>
    737           <mi>U</mi>
    738           <mrow class="MJX-TeXAtom-ORD">
    739             <mn>2</mn>
    740           </mrow>
    741         </msub>
    742         <mo>.</mo>
    743         <mspace width="thinmathspace" />
    744       </mstyle>
    745     </mrow>
    746     <annotation encoding="application/x-tex">{\displaystyle \Theta =2\pi U_{2}.\,}</annotation>
    747   </semantics>
    748 </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/145ac177710afd925efaae9ae8ba6c594b35b20b" class="mwe-math-fallback-image-inline mw-invert" aria-hidden="true" style="vertical-align: -0.671ex; width:11.077ex; height:2.509ex;" alt="\Theta = 2\pi U_2. \,"></span></dd></dl>
    749 <p>Because <i>R</i><sup>2</sup> is the square of the norm of the standard <a href="/wiki/Bivariate_normal" class="mw-redirect" title="Bivariate normal">bivariate normal</a> variable (<i>X</i>,&#160;<i>Y</i>), it has the <a href="/wiki/Chi-squared_distribution" title="Chi-squared distribution">chi-squared distribution</a> with two degrees of freedom. In the special case of two degrees of freedom, the chi-squared distribution coincides with the <a href="/wiki/Exponential_distribution" title="Exponential distribution">exponential distribution</a>, and the equation for <i>R</i><sup>2</sup> above is a simple way of generating the required exponential variate.
    750 </p>
    751 <h2><span class="mw-headline" id="Polar_form">Polar form</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Box%E2%80%93Muller_transform&amp;action=edit&amp;section=2" title="Edit section: Polar form"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></h2>
    752 <style data-mw-deduplicate="TemplateStyles:r1033289096">.mw-parser-output .hatnote{font-style:italic}.mw-parser-output div.hatnote{padding-left:1.6em;margin-bottom:0.5em}.mw-parser-output .hatnote i{font-style:normal}.mw-parser-output .hatnote+link+.hatnote{margin-top:-0.5em}</style><div role="note" class="hatnote navigation-not-searchable">Main article: <a href="/wiki/Marsaglia_polar_method" title="Marsaglia polar method">Marsaglia polar method</a></div>
    753 <figure typeof="mw:File/Thumb"><a href="/wiki/File:BoxMullerTransformUsingPolarCoordinates.png" class="mw-file-description"><img src="//upload.wikimedia.org/wikipedia/commons/thumb/d/d4/BoxMullerTransformUsingPolarCoordinates.png/400px-BoxMullerTransformUsingPolarCoordinates.png" decoding="async" width="400" height="251" class="mw-file-element" srcset="//upload.wikimedia.org/wikipedia/commons/thumb/d/d4/BoxMullerTransformUsingPolarCoordinates.png/600px-BoxMullerTransformUsingPolarCoordinates.png 1.5x, //upload.wikimedia.org/wikipedia/commons/thumb/d/d4/BoxMullerTransformUsingPolarCoordinates.png/800px-BoxMullerTransformUsingPolarCoordinates.png 2x" data-file-width="1007" data-file-height="632" /></a><figcaption>Two uniformly distributed values, <i>u</i> and <i>v</i> are used to produce the value <span class="nowrap"><i>s</i> = <i>R</i><sup>2</sup></span>, which is likewise uniformly distributed. The definitions of the sine and cosine are then applied to the basic form of the Box–Muller transform to avoid using trigonometric functions.</figcaption></figure><p> The polar form was first proposed by J. Bell<sup id="cite_ref-Bell68_6-0" class="reference"><a href="#cite_note-Bell68-6">&#91;6&#93;</a></sup> and then modified by R. Knop.<sup id="cite_ref-7" class="reference"><a href="#cite_note-7">&#91;7&#93;</a></sup> While several different versions of the polar method have been described, the version of R. Knop will be described here because it is the most widely used, in part due to its inclusion in <i><a href="/wiki/Numerical_Recipes" title="Numerical Recipes">Numerical Recipes</a></i>.  A slightly different form is described as "Algorithm P" by D. Knuth in <i><a href="/wiki/The_Art_of_Computer_Programming" title="The Art of Computer Programming">The Art of Computer Programming</a></i>.<sup id="cite_ref-8" class="reference"><a href="#cite_note-8">&#91;8&#93;</a></sup>
    754 </p><p>Given <i>u</i> and <i>v</i>, independent and uniformly distributed in the closed interval [−1,&#160;+1], set <span class="nowrap"><i>s</i> = <i>R</i><sup>2</sup> = <i>u</i><sup>2</sup> + <i>v</i><sup>2</sup></span>. If <span class="nowrap"><i>s</i> = 0</span> or <span class="nowrap"><i>s</i> ≥ 1</span>, discard <i>u</i> and <i>v</i>, and try another pair (<i>u</i>,&#160;<i>v</i>).  Because <i>u</i> and <i>v</i> are uniformly distributed and because only points within the unit circle have been admitted, the values of <i>s</i> will be uniformly distributed in the open interval (0,&#160;1), too.  The latter can be seen by calculating the cumulative distribution function for <i>s</i> in the interval (0,&#160;1).  This is the area of a circle with radius <span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML"  alttext="{\displaystyle \scriptstyle {\sqrt {s}}}">
    755   <semantics>
    756     <mrow class="MJX-TeXAtom-ORD">
    757       <mstyle displaystyle="true" scriptlevel="0">
    758         <mstyle displaystyle="false" scriptlevel="1">
    759           <mrow class="MJX-TeXAtom-ORD">
    760             <msqrt>
    761               <mi>s</mi>
    762             </msqrt>
    763           </mrow>
    764         </mstyle>
    765       </mstyle>
    766     </mrow>
    767     <annotation encoding="application/x-tex">{\displaystyle \scriptstyle {\sqrt {s}}}</annotation>
    768   </semantics>
    769 </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/a41099430a8cc26566c1c11a5155f2cedcf2fc7c" class="mwe-math-fallback-image-inline mw-invert" aria-hidden="true" style="vertical-align: -0.671ex; width:2.14ex; height:2.176ex;" alt="\scriptstyle \sqrt{s}"></span>, divided by <span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML"  alttext="{\displaystyle \scriptstyle \pi }">
    770   <semantics>
    771     <mrow class="MJX-TeXAtom-ORD">
    772       <mstyle displaystyle="true" scriptlevel="0">
    773         <mstyle displaystyle="false" scriptlevel="1">
    774           <mi>&#x03C0;<!-- π --></mi>
    775         </mstyle>
    776       </mstyle>
    777     </mrow>
    778     <annotation encoding="application/x-tex">{\displaystyle \scriptstyle \pi }</annotation>
    779   </semantics>
    780 </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/bb2635a9b35ac9dfcc9fed1229d49f5355bd3a8d" class="mwe-math-fallback-image-inline mw-invert" aria-hidden="true" style="vertical-align: -0.338ex; width:0.942ex; height:1.343ex;" alt="\scriptstyle\pi"></span>. From this we find the probability density function to have the constant value 1 on the interval (0,&#160;1). Equally so, the angle θ divided by <span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML"  alttext="{\displaystyle \scriptstyle 2\pi }">
    781   <semantics>
    782     <mrow class="MJX-TeXAtom-ORD">
    783       <mstyle displaystyle="true" scriptlevel="0">
    784         <mstyle displaystyle="false" scriptlevel="1">
    785           <mn>2</mn>
    786           <mi>&#x03C0;<!-- π --></mi>
    787         </mstyle>
    788       </mstyle>
    789     </mrow>
    790     <annotation encoding="application/x-tex">{\displaystyle \scriptstyle 2\pi }</annotation>
    791   </semantics>
    792 </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/ca1c97b2aba7cb514f08126df3889034ba5927b4" class="mwe-math-fallback-image-inline mw-invert" aria-hidden="true" style="vertical-align: -0.338ex; width:1.764ex; height:1.676ex;" alt="\scriptstyle 2 \pi"></span> is uniformly distributed in the interval [0,&#160;1) and independent of <i>s</i>.
    793 </p><p>We now identify the value of <i>s</i> with that of <i>U</i><sub>1</sub> and <span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML"  alttext="{\displaystyle \scriptstyle \theta /(2\pi )}">
    794   <semantics>
    795     <mrow class="MJX-TeXAtom-ORD">
    796       <mstyle displaystyle="true" scriptlevel="0">
    797         <mstyle displaystyle="false" scriptlevel="1">
    798           <mi>&#x03B8;<!-- θ --></mi>
    799           <mrow class="MJX-TeXAtom-ORD">
    800             <mo>/</mo>
    801           </mrow>
    802           <mo stretchy="false">(</mo>
    803           <mn>2</mn>
    804           <mi>&#x03C0;<!-- π --></mi>
    805           <mo stretchy="false">)</mo>
    806         </mstyle>
    807       </mstyle>
    808     </mrow>
    809     <annotation encoding="application/x-tex">{\displaystyle \scriptstyle \theta /(2\pi )}</annotation>
    810   </semantics>
    811 </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/98067e94723827cfc412f06eb4b506afe83bc185" class="mwe-math-fallback-image-inline mw-invert" aria-hidden="true" style="vertical-align: -0.671ex; width:4.636ex; height:2.176ex;" alt="\scriptstyle \theta/(2 \pi)"></span> with that of <i>U</i><sub>2</sub> in the basic form.  As shown in the figure, the values of <span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML"  alttext="{\displaystyle \scriptstyle \cos \theta =\cos 2\pi U_{2}}">
    812   <semantics>
    813     <mrow class="MJX-TeXAtom-ORD">
    814       <mstyle displaystyle="true" scriptlevel="0">
    815         <mstyle displaystyle="false" scriptlevel="1">
    816           <mi>cos</mi>
    817           <mo>&#x2061;<!-- ⁡ --></mo>
    818           <mi>&#x03B8;<!-- θ --></mi>
    819           <mo>=</mo>
    820           <mi>cos</mi>
    821           <mo>&#x2061;<!-- ⁡ --></mo>
    822           <mn>2</mn>
    823           <mi>&#x03C0;<!-- π --></mi>
    824           <msub>
    825             <mi>U</mi>
    826             <mrow class="MJX-TeXAtom-ORD">
    827               <mn>2</mn>
    828             </mrow>
    829           </msub>
    830         </mstyle>
    831       </mstyle>
    832     </mrow>
    833     <annotation encoding="application/x-tex">{\displaystyle \scriptstyle \cos \theta =\cos 2\pi U_{2}}</annotation>
    834   </semantics>
    835 </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/8454069b95bf2685b26b9e597caa3e2e267a55e2" class="mwe-math-fallback-image-inline mw-invert" aria-hidden="true" style="vertical-align: -0.505ex; width:10.942ex; height:1.843ex;" alt="\scriptstyle \cos \theta = \cos 2 \pi U_2"></span> and <span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML"  alttext="{\displaystyle \scriptstyle \sin \theta =\sin 2\pi U_{2}}">
    836   <semantics>
    837     <mrow class="MJX-TeXAtom-ORD">
    838       <mstyle displaystyle="true" scriptlevel="0">
    839         <mstyle displaystyle="false" scriptlevel="1">
    840           <mi>sin</mi>
    841           <mo>&#x2061;<!-- ⁡ --></mo>
    842           <mi>&#x03B8;<!-- θ --></mi>
    843           <mo>=</mo>
    844           <mi>sin</mi>
    845           <mo>&#x2061;<!-- ⁡ --></mo>
    846           <mn>2</mn>
    847           <mi>&#x03C0;<!-- π --></mi>
    848           <msub>
    849             <mi>U</mi>
    850             <mrow class="MJX-TeXAtom-ORD">
    851               <mn>2</mn>
    852             </mrow>
    853           </msub>
    854         </mstyle>
    855       </mstyle>
    856     </mrow>
    857     <annotation encoding="application/x-tex">{\displaystyle \scriptstyle \sin \theta =\sin 2\pi U_{2}}</annotation>
    858   </semantics>
    859 </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/d64a13bcc01da7101303eca350fe5a53564858d6" class="mwe-math-fallback-image-inline mw-invert" aria-hidden="true" style="vertical-align: -0.505ex; width:10.58ex; height:1.843ex;" alt="\scriptstyle \sin \theta = \sin 2 \pi U_2"></span> in the basic form can be replaced with the ratios <span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML"  alttext="{\displaystyle \scriptstyle \cos \theta =u/R=u/{\sqrt {s}}}">
    860   <semantics>
    861     <mrow class="MJX-TeXAtom-ORD">
    862       <mstyle displaystyle="true" scriptlevel="0">
    863         <mstyle displaystyle="false" scriptlevel="1">
    864           <mi>cos</mi>
    865           <mo>&#x2061;<!-- ⁡ --></mo>
    866           <mi>&#x03B8;<!-- θ --></mi>
    867           <mo>=</mo>
    868           <mi>u</mi>
    869           <mrow class="MJX-TeXAtom-ORD">
    870             <mo>/</mo>
    871           </mrow>
    872           <mi>R</mi>
    873           <mo>=</mo>
    874           <mi>u</mi>
    875           <mrow class="MJX-TeXAtom-ORD">
    876             <mo>/</mo>
    877           </mrow>
    878           <mrow class="MJX-TeXAtom-ORD">
    879             <msqrt>
    880               <mi>s</mi>
    881             </msqrt>
    882           </mrow>
    883         </mstyle>
    884       </mstyle>
    885     </mrow>
    886     <annotation encoding="application/x-tex">{\displaystyle \scriptstyle \cos \theta =u/R=u/{\sqrt {s}}}</annotation>
    887   </semantics>
    888 </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/5375f4c6b1ba089ebccbabfb7765ea28c1de0383" class="mwe-math-fallback-image-inline mw-invert" aria-hidden="true" style="vertical-align: -0.671ex; width:12.827ex; height:2.176ex;" alt="\scriptstyle\cos \theta = u/R = u/\sqrt{s}"></span> and <span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML"  alttext="{\displaystyle \scriptstyle \sin \theta =v/R=v/{\sqrt {s}}}">
    889   <semantics>
    890     <mrow class="MJX-TeXAtom-ORD">
    891       <mstyle displaystyle="true" scriptlevel="0">
    892         <mstyle displaystyle="false" scriptlevel="1">
    893           <mi>sin</mi>
    894           <mo>&#x2061;<!-- ⁡ --></mo>
    895           <mi>&#x03B8;<!-- θ --></mi>
    896           <mo>=</mo>
    897           <mi>v</mi>
    898           <mrow class="MJX-TeXAtom-ORD">
    899             <mo>/</mo>
    900           </mrow>
    901           <mi>R</mi>
    902           <mo>=</mo>
    903           <mi>v</mi>
    904           <mrow class="MJX-TeXAtom-ORD">
    905             <mo>/</mo>
    906           </mrow>
    907           <mrow class="MJX-TeXAtom-ORD">
    908             <msqrt>
    909               <mi>s</mi>
    910             </msqrt>
    911           </mrow>
    912         </mstyle>
    913       </mstyle>
    914     </mrow>
    915     <annotation encoding="application/x-tex">{\displaystyle \scriptstyle \sin \theta =v/R=v/{\sqrt {s}}}</annotation>
    916   </semantics>
    917 </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/c6190ca5e4c906826786c8ce696ea3b9ca11aefa" class="mwe-math-fallback-image-inline mw-invert" aria-hidden="true" style="vertical-align: -0.671ex; width:12.36ex; height:2.176ex;" alt="\scriptstyle\sin \theta = v/R = v/\sqrt{s}"></span>, respectively.  The advantage is that calculating the trigonometric functions directly can be avoided.  This is helpful when trigonometric functions are more expensive to compute than the single division that replaces each one.
    918 </p><p>Just as the basic form produces two standard normal deviates, so does this alternate calculation.
    919 </p>
    920 <dl><dd><span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML"  alttext="{\displaystyle z_{0}={\sqrt {-2\ln U_{1}}}\cos(2\pi U_{2})={\sqrt {-2\ln s}}\left({\frac {u}{\sqrt {s}}}\right)=u\cdot {\sqrt {\frac {-2\ln s}{s}}}}">
    921   <semantics>
    922     <mrow class="MJX-TeXAtom-ORD">
    923       <mstyle displaystyle="true" scriptlevel="0">
    924         <msub>
    925           <mi>z</mi>
    926           <mrow class="MJX-TeXAtom-ORD">
    927             <mn>0</mn>
    928           </mrow>
    929         </msub>
    930         <mo>=</mo>
    931         <mrow class="MJX-TeXAtom-ORD">
    932           <msqrt>
    933             <mo>&#x2212;<!-- − --></mo>
    934             <mn>2</mn>
    935             <mi>ln</mi>
    936             <mo>&#x2061;<!-- ⁡ --></mo>
    937             <msub>
    938               <mi>U</mi>
    939               <mrow class="MJX-TeXAtom-ORD">
    940                 <mn>1</mn>
    941               </mrow>
    942             </msub>
    943           </msqrt>
    944         </mrow>
    945         <mi>cos</mi>
    946         <mo>&#x2061;<!-- ⁡ --></mo>
    947         <mo stretchy="false">(</mo>
    948         <mn>2</mn>
    949         <mi>&#x03C0;<!-- π --></mi>
    950         <msub>
    951           <mi>U</mi>
    952           <mrow class="MJX-TeXAtom-ORD">
    953             <mn>2</mn>
    954           </mrow>
    955         </msub>
    956         <mo stretchy="false">)</mo>
    957         <mo>=</mo>
    958         <mrow class="MJX-TeXAtom-ORD">
    959           <msqrt>
    960             <mo>&#x2212;<!-- − --></mo>
    961             <mn>2</mn>
    962             <mi>ln</mi>
    963             <mo>&#x2061;<!-- ⁡ --></mo>
    964             <mi>s</mi>
    965           </msqrt>
    966         </mrow>
    967         <mrow>
    968           <mo>(</mo>
    969           <mrow class="MJX-TeXAtom-ORD">
    970             <mfrac>
    971               <mi>u</mi>
    972               <msqrt>
    973                 <mi>s</mi>
    974               </msqrt>
    975             </mfrac>
    976           </mrow>
    977           <mo>)</mo>
    978         </mrow>
    979         <mo>=</mo>
    980         <mi>u</mi>
    981         <mo>&#x22C5;<!-- ⋅ --></mo>
    982         <mrow class="MJX-TeXAtom-ORD">
    983           <msqrt>
    984             <mfrac>
    985               <mrow>
    986                 <mo>&#x2212;<!-- − --></mo>
    987                 <mn>2</mn>
    988                 <mi>ln</mi>
    989                 <mo>&#x2061;<!-- ⁡ --></mo>
    990                 <mi>s</mi>
    991               </mrow>
    992               <mi>s</mi>
    993             </mfrac>
    994           </msqrt>
    995         </mrow>
    996       </mstyle>
    997     </mrow>
    998     <annotation encoding="application/x-tex">{\displaystyle z_{0}={\sqrt {-2\ln U_{1}}}\cos(2\pi U_{2})={\sqrt {-2\ln s}}\left({\frac {u}{\sqrt {s}}}\right)=u\cdot {\sqrt {\frac {-2\ln s}{s}}}}</annotation>
    999   </semantics>
   1000 </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/e40643ede00b3902399f6ec449eed868a7edb734" class="mwe-math-fallback-image-inline mw-invert" aria-hidden="true" style="vertical-align: -2.838ex; width:61.849ex; height:6.676ex;" alt="z_0 = \sqrt{-2 \ln U_1} \cos(2 \pi U_2) = \sqrt{-2 \ln s} \left(\frac{u}{\sqrt{s}}\right) = u \cdot \sqrt{\frac{-2 \ln s}{s}}"></span></dd></dl>
   1001 <p>and
   1002 </p>
   1003 <dl><dd><span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML"  alttext="{\displaystyle z_{1}={\sqrt {-2\ln U_{1}}}\sin(2\pi U_{2})={\sqrt {-2\ln s}}\left({\frac {v}{\sqrt {s}}}\right)=v\cdot {\sqrt {\frac {-2\ln s}{s}}}.}">
   1004   <semantics>
   1005     <mrow class="MJX-TeXAtom-ORD">
   1006       <mstyle displaystyle="true" scriptlevel="0">
   1007         <msub>
   1008           <mi>z</mi>
   1009           <mrow class="MJX-TeXAtom-ORD">
   1010             <mn>1</mn>
   1011           </mrow>
   1012         </msub>
   1013         <mo>=</mo>
   1014         <mrow class="MJX-TeXAtom-ORD">
   1015           <msqrt>
   1016             <mo>&#x2212;<!-- − --></mo>
   1017             <mn>2</mn>
   1018             <mi>ln</mi>
   1019             <mo>&#x2061;<!-- ⁡ --></mo>
   1020             <msub>
   1021               <mi>U</mi>
   1022               <mrow class="MJX-TeXAtom-ORD">
   1023                 <mn>1</mn>
   1024               </mrow>
   1025             </msub>
   1026           </msqrt>
   1027         </mrow>
   1028         <mi>sin</mi>
   1029         <mo>&#x2061;<!-- ⁡ --></mo>
   1030         <mo stretchy="false">(</mo>
   1031         <mn>2</mn>
   1032         <mi>&#x03C0;<!-- π --></mi>
   1033         <msub>
   1034           <mi>U</mi>
   1035           <mrow class="MJX-TeXAtom-ORD">
   1036             <mn>2</mn>
   1037           </mrow>
   1038         </msub>
   1039         <mo stretchy="false">)</mo>
   1040         <mo>=</mo>
   1041         <mrow class="MJX-TeXAtom-ORD">
   1042           <msqrt>
   1043             <mo>&#x2212;<!-- − --></mo>
   1044             <mn>2</mn>
   1045             <mi>ln</mi>
   1046             <mo>&#x2061;<!-- ⁡ --></mo>
   1047             <mi>s</mi>
   1048           </msqrt>
   1049         </mrow>
   1050         <mrow>
   1051           <mo>(</mo>
   1052           <mrow class="MJX-TeXAtom-ORD">
   1053             <mfrac>
   1054               <mi>v</mi>
   1055               <msqrt>
   1056                 <mi>s</mi>
   1057               </msqrt>
   1058             </mfrac>
   1059           </mrow>
   1060           <mo>)</mo>
   1061         </mrow>
   1062         <mo>=</mo>
   1063         <mi>v</mi>
   1064         <mo>&#x22C5;<!-- ⋅ --></mo>
   1065         <mrow class="MJX-TeXAtom-ORD">
   1066           <msqrt>
   1067             <mfrac>
   1068               <mrow>
   1069                 <mo>&#x2212;<!-- − --></mo>
   1070                 <mn>2</mn>
   1071                 <mi>ln</mi>
   1072                 <mo>&#x2061;<!-- ⁡ --></mo>
   1073                 <mi>s</mi>
   1074               </mrow>
   1075               <mi>s</mi>
   1076             </mfrac>
   1077           </msqrt>
   1078         </mrow>
   1079         <mo>.</mo>
   1080       </mstyle>
   1081     </mrow>
   1082     <annotation encoding="application/x-tex">{\displaystyle z_{1}={\sqrt {-2\ln U_{1}}}\sin(2\pi U_{2})={\sqrt {-2\ln s}}\left({\frac {v}{\sqrt {s}}}\right)=v\cdot {\sqrt {\frac {-2\ln s}{s}}}.}</annotation>
   1083   </semantics>
   1084 </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/5c7c0d13474cc0cdf0b4893a2ad8595f8b51d852" class="mwe-math-fallback-image-inline mw-invert" aria-hidden="true" style="vertical-align: -2.838ex; width:62.038ex; height:6.676ex;" alt="z_1 = \sqrt{-2 \ln U_1} \sin(2 \pi U_2) = \sqrt{-2 \ln s}\left( \frac{v}{\sqrt{s}}\right) = v \cdot \sqrt{\frac{-2 \ln s}{s}}."></span></dd></dl>
   1085 <h2><span class="mw-headline" id="Contrasting_the_two_forms">Contrasting the two forms</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Box%E2%80%93Muller_transform&amp;action=edit&amp;section=3" title="Edit section: Contrasting the two forms"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></h2>
   1086 <p>The polar method differs from the basic method in that it is a type of <a href="/wiki/Rejection_sampling" title="Rejection sampling">rejection sampling</a>.  It discards some generated random numbers, but can be faster than the basic method because it is simpler to compute (provided that the random number generator is relatively fast) and is more numerically robust.<sup id="cite_ref-Carter_9-0" class="reference"><a href="#cite_note-Carter-9">&#91;9&#93;</a></sup> Avoiding the use of expensive trigonometric functions improves speed over the basic form.<sup id="cite_ref-Bell68_6-1" class="reference"><a href="#cite_note-Bell68-6">&#91;6&#93;</a></sup> It discards <span class="nowrap">1 − <span class="texhtml mvar" style="font-style:italic;">π</span>/4 ≈ 21.46%</span> of the total input uniformly distributed random number pairs generated, i.e. discards <span class="nowrap">4/<span class="texhtml mvar" style="font-style:italic;">π</span> − 1 ≈ 27.32%</span> uniformly distributed random number pairs per <a href="/wiki/Normal_distribution" title="Normal distribution">Gaussian</a> random number pair generated, requiring <span class="nowrap">4/<span class="texhtml mvar" style="font-style:italic;">π</span> ≈ 1.2732</span> input random numbers per output random number.
   1087 </p><p>The basic form requires two multiplications, 1/2 logarithm, 1/2 square root, and one trigonometric function for each normal variate.<sup id="cite_ref-10" class="reference"><a href="#cite_note-10">&#91;10&#93;</a></sup> On some processors, the cosine and sine of the same argument can be calculated in parallel using a single instruction. Notably for Intel-based machines, one can use the fsincos assembler instruction or the expi instruction (usually available from C as an <a href="/wiki/Intrinsic_function" title="Intrinsic function">intrinsic function</a>), to calculate complex
   1088 </p>
   1089 <dl><dd><span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML"  alttext="{\displaystyle \exp(iz)=e^{iz}=\cos z+i\sin z,\,}">
   1090   <semantics>
   1091     <mrow class="MJX-TeXAtom-ORD">
   1092       <mstyle displaystyle="true" scriptlevel="0">
   1093         <mi>exp</mi>
   1094         <mo>&#x2061;<!-- ⁡ --></mo>
   1095         <mo stretchy="false">(</mo>
   1096         <mi>i</mi>
   1097         <mi>z</mi>
   1098         <mo stretchy="false">)</mo>
   1099         <mo>=</mo>
   1100         <msup>
   1101           <mi>e</mi>
   1102           <mrow class="MJX-TeXAtom-ORD">
   1103             <mi>i</mi>
   1104             <mi>z</mi>
   1105           </mrow>
   1106         </msup>
   1107         <mo>=</mo>
   1108         <mi>cos</mi>
   1109         <mo>&#x2061;<!-- ⁡ --></mo>
   1110         <mi>z</mi>
   1111         <mo>+</mo>
   1112         <mi>i</mi>
   1113         <mi>sin</mi>
   1114         <mo>&#x2061;<!-- ⁡ --></mo>
   1115         <mi>z</mi>
   1116         <mo>,</mo>
   1117         <mspace width="thinmathspace" />
   1118       </mstyle>
   1119     </mrow>
   1120     <annotation encoding="application/x-tex">{\displaystyle \exp(iz)=e^{iz}=\cos z+i\sin z,\,}</annotation>
   1121   </semantics>
   1122 </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/155b08d9d1897e1de951c73317a5b44ad488131d" class="mwe-math-fallback-image-inline mw-invert" aria-hidden="true" style="vertical-align: -0.838ex; width:30.083ex; height:3.176ex;" alt="{\displaystyle \exp(iz)=e^{iz}=\cos z+i\sin z,\,}"></span></dd></dl>
   1123 <p>and just separate the real and imaginary parts.
   1124 </p><p><b>Note:</b> 
   1125 To explicitly calculate the complex-polar form use the following substitutions in the general form,
   1126 </p><p>Let <span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML"  alttext="{\displaystyle r={\sqrt {-\ln(u_{1})}}}">
   1127   <semantics>
   1128     <mrow class="MJX-TeXAtom-ORD">
   1129       <mstyle displaystyle="true" scriptlevel="0">
   1130         <mi>r</mi>
   1131         <mo>=</mo>
   1132         <mrow class="MJX-TeXAtom-ORD">
   1133           <msqrt>
   1134             <mo>&#x2212;<!-- − --></mo>
   1135             <mi>ln</mi>
   1136             <mo>&#x2061;<!-- ⁡ --></mo>
   1137             <mo stretchy="false">(</mo>
   1138             <msub>
   1139               <mi>u</mi>
   1140               <mrow class="MJX-TeXAtom-ORD">
   1141                 <mn>1</mn>
   1142               </mrow>
   1143             </msub>
   1144             <mo stretchy="false">)</mo>
   1145           </msqrt>
   1146         </mrow>
   1147       </mstyle>
   1148     </mrow>
   1149     <annotation encoding="application/x-tex">{\displaystyle r={\sqrt {-\ln(u_{1})}}}</annotation>
   1150   </semantics>
   1151 </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/5a9257650a4e53b6ffb5368b15d5713dddf2005e" class="mwe-math-fallback-image-inline mw-invert" aria-hidden="true" style="vertical-align: -1.838ex; width:14.799ex; height:4.843ex;" alt="{\displaystyle r={\sqrt {-\ln(u_{1})}}}"></span> and <span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML"  alttext="{\displaystyle z=2\pi u_{2}.}">
   1152   <semantics>
   1153     <mrow class="MJX-TeXAtom-ORD">
   1154       <mstyle displaystyle="true" scriptlevel="0">
   1155         <mi>z</mi>
   1156         <mo>=</mo>
   1157         <mn>2</mn>
   1158         <mi>&#x03C0;<!-- π --></mi>
   1159         <msub>
   1160           <mi>u</mi>
   1161           <mrow class="MJX-TeXAtom-ORD">
   1162             <mn>2</mn>
   1163           </mrow>
   1164         </msub>
   1165         <mo>.</mo>
   1166       </mstyle>
   1167     </mrow>
   1168     <annotation encoding="application/x-tex">{\displaystyle z=2\pi u_{2}.}</annotation>
   1169   </semantics>
   1170 </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/e2b786079f38d943357a77df48ba50f0244dd91d" class="mwe-math-fallback-image-inline mw-invert" aria-hidden="true" style="vertical-align: -0.671ex; width:9.712ex; height:2.509ex;" alt="{\displaystyle z=2\pi u_{2}.}"></span> Then
   1171 </p>
   1172 <dl><dd><span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML"  alttext="{\displaystyle re^{iz}={\sqrt {-\ln(u_{1})}}e^{i2\pi u_{2}}={\sqrt {-2\ln(u_{1})}}\left[\cos(2\pi u_{2})+i\sin(2\pi u_{2})\right].}">
   1173   <semantics>
   1174     <mrow class="MJX-TeXAtom-ORD">
   1175       <mstyle displaystyle="true" scriptlevel="0">
   1176         <mi>r</mi>
   1177         <msup>
   1178           <mi>e</mi>
   1179           <mrow class="MJX-TeXAtom-ORD">
   1180             <mi>i</mi>
   1181             <mi>z</mi>
   1182           </mrow>
   1183         </msup>
   1184         <mo>=</mo>
   1185         <mrow class="MJX-TeXAtom-ORD">
   1186           <msqrt>
   1187             <mo>&#x2212;<!-- − --></mo>
   1188             <mi>ln</mi>
   1189             <mo>&#x2061;<!-- ⁡ --></mo>
   1190             <mo stretchy="false">(</mo>
   1191             <msub>
   1192               <mi>u</mi>
   1193               <mrow class="MJX-TeXAtom-ORD">
   1194                 <mn>1</mn>
   1195               </mrow>
   1196             </msub>
   1197             <mo stretchy="false">)</mo>
   1198           </msqrt>
   1199         </mrow>
   1200         <msup>
   1201           <mi>e</mi>
   1202           <mrow class="MJX-TeXAtom-ORD">
   1203             <mi>i</mi>
   1204             <mn>2</mn>
   1205             <mi>&#x03C0;<!-- π --></mi>
   1206             <msub>
   1207               <mi>u</mi>
   1208               <mrow class="MJX-TeXAtom-ORD">
   1209                 <mn>2</mn>
   1210               </mrow>
   1211             </msub>
   1212           </mrow>
   1213         </msup>
   1214         <mo>=</mo>
   1215         <mrow class="MJX-TeXAtom-ORD">
   1216           <msqrt>
   1217             <mo>&#x2212;<!-- − --></mo>
   1218             <mn>2</mn>
   1219             <mi>ln</mi>
   1220             <mo>&#x2061;<!-- ⁡ --></mo>
   1221             <mo stretchy="false">(</mo>
   1222             <msub>
   1223               <mi>u</mi>
   1224               <mrow class="MJX-TeXAtom-ORD">
   1225                 <mn>1</mn>
   1226               </mrow>
   1227             </msub>
   1228             <mo stretchy="false">)</mo>
   1229           </msqrt>
   1230         </mrow>
   1231         <mrow>
   1232           <mo>[</mo>
   1233           <mrow>
   1234             <mi>cos</mi>
   1235             <mo>&#x2061;<!-- ⁡ --></mo>
   1236             <mo stretchy="false">(</mo>
   1237             <mn>2</mn>
   1238             <mi>&#x03C0;<!-- π --></mi>
   1239             <msub>
   1240               <mi>u</mi>
   1241               <mrow class="MJX-TeXAtom-ORD">
   1242                 <mn>2</mn>
   1243               </mrow>
   1244             </msub>
   1245             <mo stretchy="false">)</mo>
   1246             <mo>+</mo>
   1247             <mi>i</mi>
   1248             <mi>sin</mi>
   1249             <mo>&#x2061;<!-- ⁡ --></mo>
   1250             <mo stretchy="false">(</mo>
   1251             <mn>2</mn>
   1252             <mi>&#x03C0;<!-- π --></mi>
   1253             <msub>
   1254               <mi>u</mi>
   1255               <mrow class="MJX-TeXAtom-ORD">
   1256                 <mn>2</mn>
   1257               </mrow>
   1258             </msub>
   1259             <mo stretchy="false">)</mo>
   1260           </mrow>
   1261           <mo>]</mo>
   1262         </mrow>
   1263         <mo>.</mo>
   1264       </mstyle>
   1265     </mrow>
   1266     <annotation encoding="application/x-tex">{\displaystyle re^{iz}={\sqrt {-\ln(u_{1})}}e^{i2\pi u_{2}}={\sqrt {-2\ln(u_{1})}}\left[\cos(2\pi u_{2})+i\sin(2\pi u_{2})\right].}</annotation>
   1267   </semantics>
   1268 </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/cde981cf6a8d8e6c83066f1c68f3f40804b9ece6" class="mwe-math-fallback-image-inline mw-invert" aria-hidden="true" style="vertical-align: -1.838ex; width:63.869ex; height:4.843ex;" alt="{\displaystyle re^{iz}={\sqrt {-\ln(u_{1})}}e^{i2\pi u_{2}}={\sqrt {-2\ln(u_{1})}}\left[\cos(2\pi u_{2})+i\sin(2\pi u_{2})\right].}"></span></dd></dl>
   1269 <p>The polar form requires 3/2 multiplications, 1/2 logarithm, 1/2 square root, and 1/2 division for each normal variate.  The effect is to replace one multiplication and one trigonometric function with a single division and a conditional loop.
   1270 </p>
   1271 <h2><span class="mw-headline" id="Tails_truncation">Tails truncation</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Box%E2%80%93Muller_transform&amp;action=edit&amp;section=4" title="Edit section: Tails truncation"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></h2>
   1272 <p>When a computer is used to produce a uniform random variable it will inevitably have some inaccuracies because there is a lower bound on how close numbers can be to 0. If the generator uses 32 bits per output value, the smallest non-zero number that can be generated is <span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML"  alttext="{\displaystyle 2^{-32}}">
   1273   <semantics>
   1274     <mrow class="MJX-TeXAtom-ORD">
   1275       <mstyle displaystyle="true" scriptlevel="0">
   1276         <msup>
   1277           <mn>2</mn>
   1278           <mrow class="MJX-TeXAtom-ORD">
   1279             <mo>&#x2212;<!-- − --></mo>
   1280             <mn>32</mn>
   1281           </mrow>
   1282         </msup>
   1283       </mstyle>
   1284     </mrow>
   1285     <annotation encoding="application/x-tex">{\displaystyle 2^{-32}}</annotation>
   1286   </semantics>
   1287 </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/f6c5244b1622127f7f8009d261fca9759696ce5c" class="mwe-math-fallback-image-inline mw-invert" aria-hidden="true" style="vertical-align: -0.338ex; width:4.317ex; height:2.676ex;" alt="2^{-32}"></span>. When <span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML"  alttext="{\displaystyle U_{1}}">
   1288   <semantics>
   1289     <mrow class="MJX-TeXAtom-ORD">
   1290       <mstyle displaystyle="true" scriptlevel="0">
   1291         <msub>
   1292           <mi>U</mi>
   1293           <mrow class="MJX-TeXAtom-ORD">
   1294             <mn>1</mn>
   1295           </mrow>
   1296         </msub>
   1297       </mstyle>
   1298     </mrow>
   1299     <annotation encoding="application/x-tex">{\displaystyle U_{1}}</annotation>
   1300   </semantics>
   1301 </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/bc9e7f892894bc50c32ce1b9f9a68a15562146ac" class="mwe-math-fallback-image-inline mw-invert" aria-hidden="true" style="vertical-align: -0.671ex; width:2.642ex; height:2.509ex;" alt="U_{1}"></span> and <span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML"  alttext="{\displaystyle U_{2}}">
   1302   <semantics>
   1303     <mrow class="MJX-TeXAtom-ORD">
   1304       <mstyle displaystyle="true" scriptlevel="0">
   1305         <msub>
   1306           <mi>U</mi>
   1307           <mrow class="MJX-TeXAtom-ORD">
   1308             <mn>2</mn>
   1309           </mrow>
   1310         </msub>
   1311       </mstyle>
   1312     </mrow>
   1313     <annotation encoding="application/x-tex">{\displaystyle U_{2}}</annotation>
   1314   </semantics>
   1315 </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/590fa6a550fbe2866a28243a733d54245d218b9d" class="mwe-math-fallback-image-inline mw-invert" aria-hidden="true" style="vertical-align: -0.671ex; width:2.642ex; height:2.509ex;" alt="U_{2}"></span> are equal to this the Box–Muller transform produces a normal random deviate equal to <span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML"  alttext="{\displaystyle \delta ={\sqrt {-2\ln(2^{-32})}}\cos(2\pi 2^{-32})\approx 6.660}">
   1316   <semantics>
   1317     <mrow class="MJX-TeXAtom-ORD">
   1318       <mstyle displaystyle="true" scriptlevel="0">
   1319         <mi>&#x03B4;<!-- δ --></mi>
   1320         <mo>=</mo>
   1321         <mrow class="MJX-TeXAtom-ORD">
   1322           <msqrt>
   1323             <mo>&#x2212;<!-- − --></mo>
   1324             <mn>2</mn>
   1325             <mi>ln</mi>
   1326             <mo>&#x2061;<!-- ⁡ --></mo>
   1327             <mo stretchy="false">(</mo>
   1328             <msup>
   1329               <mn>2</mn>
   1330               <mrow class="MJX-TeXAtom-ORD">
   1331                 <mo>&#x2212;<!-- − --></mo>
   1332                 <mn>32</mn>
   1333               </mrow>
   1334             </msup>
   1335             <mo stretchy="false">)</mo>
   1336           </msqrt>
   1337         </mrow>
   1338         <mi>cos</mi>
   1339         <mo>&#x2061;<!-- ⁡ --></mo>
   1340         <mo stretchy="false">(</mo>
   1341         <mn>2</mn>
   1342         <mi>&#x03C0;<!-- π --></mi>
   1343         <msup>
   1344           <mn>2</mn>
   1345           <mrow class="MJX-TeXAtom-ORD">
   1346             <mo>&#x2212;<!-- − --></mo>
   1347             <mn>32</mn>
   1348           </mrow>
   1349         </msup>
   1350         <mo stretchy="false">)</mo>
   1351         <mo>&#x2248;<!-- ≈ --></mo>
   1352         <mn>6.660</mn>
   1353       </mstyle>
   1354     </mrow>
   1355     <annotation encoding="application/x-tex">{\displaystyle \delta ={\sqrt {-2\ln(2^{-32})}}\cos(2\pi 2^{-32})\approx 6.660}</annotation>
   1356   </semantics>
   1357 </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/30814f8ae2ee8bd162765625874be9c2d33f9ef0" class="mwe-math-fallback-image-inline mw-invert" aria-hidden="true" style="vertical-align: -1.671ex; width:38.409ex; height:4.843ex;" alt="{\displaystyle \delta ={\sqrt {-2\ln(2^{-32})}}\cos(2\pi 2^{-32})\approx 6.660}"></span>. This means that the algorithm will not produce random variables more than 6.660 standard deviations from the mean. This corresponds to a proportion of <span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML"  alttext="{\displaystyle 2(1-\Phi (\delta ))\simeq 2.738\times 10^{-11}}">
   1358   <semantics>
   1359     <mrow class="MJX-TeXAtom-ORD">
   1360       <mstyle displaystyle="true" scriptlevel="0">
   1361         <mn>2</mn>
   1362         <mo stretchy="false">(</mo>
   1363         <mn>1</mn>
   1364         <mo>&#x2212;<!-- − --></mo>
   1365         <mi mathvariant="normal">&#x03A6;<!-- Φ --></mi>
   1366         <mo stretchy="false">(</mo>
   1367         <mi>&#x03B4;<!-- δ --></mi>
   1368         <mo stretchy="false">)</mo>
   1369         <mo stretchy="false">)</mo>
   1370         <mo>&#x2243;<!-- ≃ --></mo>
   1371         <mn>2.738</mn>
   1372         <mo>&#x00D7;<!-- × --></mo>
   1373         <msup>
   1374           <mn>10</mn>
   1375           <mrow class="MJX-TeXAtom-ORD">
   1376             <mo>&#x2212;<!-- − --></mo>
   1377             <mn>11</mn>
   1378           </mrow>
   1379         </msup>
   1380       </mstyle>
   1381     </mrow>
   1382     <annotation encoding="application/x-tex">{\displaystyle 2(1-\Phi (\delta ))\simeq 2.738\times 10^{-11}}</annotation>
   1383   </semantics>
   1384 </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/fb7a55c8ee4eab71c470cc46b1979b383dd69aa2" class="mwe-math-fallback-image-inline mw-invert" aria-hidden="true" style="vertical-align: -0.838ex; width:28.226ex; height:3.176ex;" alt="{\displaystyle 2(1-\Phi (\delta ))\simeq 2.738\times 10^{-11}}"></span> lost due to the truncation, where <span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML"  alttext="{\displaystyle \Phi (\delta )}">
   1385   <semantics>
   1386     <mrow class="MJX-TeXAtom-ORD">
   1387       <mstyle displaystyle="true" scriptlevel="0">
   1388         <mi mathvariant="normal">&#x03A6;<!-- Φ --></mi>
   1389         <mo stretchy="false">(</mo>
   1390         <mi>&#x03B4;<!-- δ --></mi>
   1391         <mo stretchy="false">)</mo>
   1392       </mstyle>
   1393     </mrow>
   1394     <annotation encoding="application/x-tex">{\displaystyle \Phi (\delta )}</annotation>
   1395   </semantics>
   1396 </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/73d36f5d5452ae04596ff3d4d22145599c892478" class="mwe-math-fallback-image-inline mw-invert" aria-hidden="true" style="vertical-align: -0.838ex; width:4.536ex; height:2.843ex;" alt="{\displaystyle \Phi (\delta )}"></span> is the standard cumulative normal distribution. With 64 bits the limit is pushed to <span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML"  alttext="{\displaystyle \delta =9.419}">
   1397   <semantics>
   1398     <mrow class="MJX-TeXAtom-ORD">
   1399       <mstyle displaystyle="true" scriptlevel="0">
   1400         <mi>&#x03B4;<!-- δ --></mi>
   1401         <mo>=</mo>
   1402         <mn>9.419</mn>
   1403       </mstyle>
   1404     </mrow>
   1405     <annotation encoding="application/x-tex">{\displaystyle \delta =9.419}</annotation>
   1406   </semantics>
   1407 </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/8f742fca42e09bdf8f32968e17f281dd2522a51b" class="mwe-math-fallback-image-inline mw-invert" aria-hidden="true" style="vertical-align: -0.338ex; width:9.444ex; height:2.343ex;" alt="{\displaystyle \delta =9.419}"></span> standard deviations, for which <span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML"  alttext="{\displaystyle 2(1-\Phi (\delta ))&lt;5\times 10^{-21}}">
   1408   <semantics>
   1409     <mrow class="MJX-TeXAtom-ORD">
   1410       <mstyle displaystyle="true" scriptlevel="0">
   1411         <mn>2</mn>
   1412         <mo stretchy="false">(</mo>
   1413         <mn>1</mn>
   1414         <mo>&#x2212;<!-- − --></mo>
   1415         <mi mathvariant="normal">&#x03A6;<!-- Φ --></mi>
   1416         <mo stretchy="false">(</mo>
   1417         <mi>&#x03B4;<!-- δ --></mi>
   1418         <mo stretchy="false">)</mo>
   1419         <mo stretchy="false">)</mo>
   1420         <mo>&lt;</mo>
   1421         <mn>5</mn>
   1422         <mo>&#x00D7;<!-- × --></mo>
   1423         <msup>
   1424           <mn>10</mn>
   1425           <mrow class="MJX-TeXAtom-ORD">
   1426             <mo>&#x2212;<!-- − --></mo>
   1427             <mn>21</mn>
   1428           </mrow>
   1429         </msup>
   1430       </mstyle>
   1431     </mrow>
   1432     <annotation encoding="application/x-tex">{\displaystyle 2(1-\Phi (\delta ))&lt;5\times 10^{-21}}</annotation>
   1433   </semantics>
   1434 </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/ddf8782d5f1f7bc7ebf99e4fa8e976e2c617e4f1" class="mwe-math-fallback-image-inline mw-invert" aria-hidden="true" style="vertical-align: -0.838ex; width:24.092ex; height:3.176ex;" alt="{\displaystyle 2(1-\Phi (\delta ))&lt;5\times 10^{-21}}"></span>.
   1435 </p>
   1436 <h2><span class="mw-headline" id="Implementation">Implementation</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Box%E2%80%93Muller_transform&amp;action=edit&amp;section=5" title="Edit section: Implementation"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></h2>
   1437 <p>The standard Box–Muller transform generates values from the standard normal distribution (<i>i.e.</i> <a href="/wiki/Standard_normal_deviate" title="Standard normal deviate">standard normal deviates</a>) with mean <i>0</i> and standard deviation <i>1</i>. The implementation below in standard <a href="/wiki/C%2B%2B" title="C++">C++</a> generates values from any normal distribution with mean <span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML"  alttext="{\displaystyle \mu }">
   1438   <semantics>
   1439     <mrow class="MJX-TeXAtom-ORD">
   1440       <mstyle displaystyle="true" scriptlevel="0">
   1441         <mi>&#x03BC;<!-- μ --></mi>
   1442       </mstyle>
   1443     </mrow>
   1444     <annotation encoding="application/x-tex">{\displaystyle \mu }</annotation>
   1445   </semantics>
   1446 </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/9fd47b2a39f7a7856952afec1f1db72c67af6161" class="mwe-math-fallback-image-inline mw-invert" aria-hidden="true" style="vertical-align: -0.838ex; width:1.402ex; height:2.176ex;" alt="\mu "></span> and variance <span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML"  alttext="{\displaystyle \sigma ^{2}}">
   1447   <semantics>
   1448     <mrow class="MJX-TeXAtom-ORD">
   1449       <mstyle displaystyle="true" scriptlevel="0">
   1450         <msup>
   1451           <mi>&#x03C3;<!-- σ --></mi>
   1452           <mrow class="MJX-TeXAtom-ORD">
   1453             <mn>2</mn>
   1454           </mrow>
   1455         </msup>
   1456       </mstyle>
   1457     </mrow>
   1458     <annotation encoding="application/x-tex">{\displaystyle \sigma ^{2}}</annotation>
   1459   </semantics>
   1460 </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/53a5c55e536acf250c1d3e0f754be5692b843ef5" class="mwe-math-fallback-image-inline mw-invert" aria-hidden="true" style="vertical-align: -0.338ex; width:2.385ex; height:2.676ex;" alt="\sigma ^{2}"></span>.  If <span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML"  alttext="{\displaystyle Z}">
   1461   <semantics>
   1462     <mrow class="MJX-TeXAtom-ORD">
   1463       <mstyle displaystyle="true" scriptlevel="0">
   1464         <mi>Z</mi>
   1465       </mstyle>
   1466     </mrow>
   1467     <annotation encoding="application/x-tex">{\displaystyle Z}</annotation>
   1468   </semantics>
   1469 </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/1cc6b75e09a8aa3f04d8584b11db534f88fb56bd" class="mwe-math-fallback-image-inline mw-invert" aria-hidden="true" style="vertical-align: -0.338ex; width:1.68ex; height:2.176ex;" alt="Z"></span> is a standard normal deviate, then <span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML"  alttext="{\displaystyle X=Z\sigma +\mu }">
   1470   <semantics>
   1471     <mrow class="MJX-TeXAtom-ORD">
   1472       <mstyle displaystyle="true" scriptlevel="0">
   1473         <mi>X</mi>
   1474         <mo>=</mo>
   1475         <mi>Z</mi>
   1476         <mi>&#x03C3;<!-- σ --></mi>
   1477         <mo>+</mo>
   1478         <mi>&#x03BC;<!-- μ --></mi>
   1479       </mstyle>
   1480     </mrow>
   1481     <annotation encoding="application/x-tex">{\displaystyle X=Z\sigma +\mu }</annotation>
   1482   </semantics>
   1483 </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/cce5cc456b46bf59dc2c6374a2cc30f0246e1a5e" class="mwe-math-fallback-image-inline mw-invert" aria-hidden="true" style="vertical-align: -0.838ex; width:12.331ex; height:2.676ex;" alt="X=Z\sigma +\mu "></span> will have a normal distribution with mean <span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML"  alttext="{\displaystyle \mu }">
   1484   <semantics>
   1485     <mrow class="MJX-TeXAtom-ORD">
   1486       <mstyle displaystyle="true" scriptlevel="0">
   1487         <mi>&#x03BC;<!-- μ --></mi>
   1488       </mstyle>
   1489     </mrow>
   1490     <annotation encoding="application/x-tex">{\displaystyle \mu }</annotation>
   1491   </semantics>
   1492 </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/9fd47b2a39f7a7856952afec1f1db72c67af6161" class="mwe-math-fallback-image-inline mw-invert" aria-hidden="true" style="vertical-align: -0.838ex; width:1.402ex; height:2.176ex;" alt="\mu "></span> and standard deviation <span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML"  alttext="{\displaystyle \sigma }">
   1493   <semantics>
   1494     <mrow class="MJX-TeXAtom-ORD">
   1495       <mstyle displaystyle="true" scriptlevel="0">
   1496         <mi>&#x03C3;<!-- σ --></mi>
   1497       </mstyle>
   1498     </mrow>
   1499     <annotation encoding="application/x-tex">{\displaystyle \sigma }</annotation>
   1500   </semantics>
   1501 </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/59f59b7c3e6fdb1d0365a494b81fb9a696138c36" class="mwe-math-fallback-image-inline mw-invert" aria-hidden="true" style="vertical-align: -0.338ex; width:1.33ex; height:1.676ex;" alt="\sigma "></span>.  The random number generator has been <a href="/wiki/Random_seed" title="Random seed">seeded</a> to ensure that new, pseudo-random values will be returned from sequential calls to the <code>generateGaussianNoise</code> function.
   1502 </p>
   1503 <div class="mw-highlight mw-highlight-lang-cpp mw-content-ltr" dir="ltr"><pre><span></span><span class="cp">#include</span><span class="w"> </span><span class="cpf">&lt;cmath&gt;</span>
   1504 <span class="cp">#include</span><span class="w"> </span><span class="cpf">&lt;limits&gt;</span>
   1505 <span class="cp">#include</span><span class="w"> </span><span class="cpf">&lt;random&gt;</span>
   1506 <span class="cp">#include</span><span class="w"> </span><span class="cpf">&lt;utility&gt;</span>
   1507 
   1508 <span class="c1">//&quot;mu&quot; is the mean of the distribution, and &quot;sigma&quot; is the standard deviation.</span>
   1509 <span class="n">std</span><span class="o">::</span><span class="n">pair</span><span class="o">&lt;</span><span class="kt">double</span><span class="p">,</span><span class="w"> </span><span class="kt">double</span><span class="o">&gt;</span><span class="w"> </span><span class="n">generateGaussianNoise</span><span class="p">(</span><span class="kt">double</span><span class="w"> </span><span class="n">mu</span><span class="p">,</span><span class="w"> </span><span class="kt">double</span><span class="w"> </span><span class="n">sigma</span><span class="p">)</span>
   1510 <span class="p">{</span>
   1511 <span class="w">    </span><span class="k">constexpr</span><span class="w"> </span><span class="kt">double</span><span class="w"> </span><span class="n">epsilon</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">std</span><span class="o">::</span><span class="n">numeric_limits</span><span class="o">&lt;</span><span class="kt">double</span><span class="o">&gt;::</span><span class="n">epsilon</span><span class="p">();</span>
   1512 <span class="w">    </span><span class="k">constexpr</span><span class="w"> </span><span class="kt">double</span><span class="w"> </span><span class="n">two_pi</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">2.0</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="n">M_PI</span><span class="p">;</span>
   1513 
   1514 <span class="w">    </span><span class="c1">//initialize the random uniform number generator (runif) in a range 0 to 1</span>
   1515 <span class="w">    </span><span class="k">static</span><span class="w"> </span><span class="n">std</span><span class="o">::</span><span class="n">mt19937</span><span class="w"> </span><span class="nf">rng</span><span class="p">(</span><span class="n">std</span><span class="o">::</span><span class="n">random_device</span><span class="p">{}());</span><span class="w"> </span><span class="c1">// Standard mersenne_twister_engine seeded with rd()</span>
   1516 <span class="w">    </span><span class="k">static</span><span class="w"> </span><span class="n">std</span><span class="o">::</span><span class="n">uniform_real_distribution</span><span class="o">&lt;&gt;</span><span class="w"> </span><span class="n">runif</span><span class="p">(</span><span class="mf">0.0</span><span class="p">,</span><span class="w"> </span><span class="mf">1.0</span><span class="p">);</span>
   1517 
   1518 <span class="w">    </span><span class="c1">//create two random numbers, make sure u1 is greater than epsilon</span>
   1519 <span class="w">    </span><span class="kt">double</span><span class="w"> </span><span class="n">u1</span><span class="p">,</span><span class="w"> </span><span class="n">u2</span><span class="p">;</span>
   1520 <span class="w">    </span><span class="k">do</span>
   1521 <span class="w">    </span><span class="p">{</span>
   1522 <span class="w">        </span><span class="n">u1</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">runif</span><span class="p">(</span><span class="n">rng</span><span class="p">);</span>
   1523 <span class="w">    </span><span class="p">}</span>
   1524 <span class="w">    </span><span class="k">while</span><span class="w"> </span><span class="p">(</span><span class="n">u1</span><span class="w"> </span><span class="o">&lt;=</span><span class="w"> </span><span class="n">epsilon</span><span class="p">);</span>
   1525 <span class="w">    </span><span class="n">u2</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">runif</span><span class="p">(</span><span class="n">rng</span><span class="p">);</span>
   1526 
   1527 <span class="w">    </span><span class="c1">//compute z0 and z1</span>
   1528 <span class="w">    </span><span class="k">auto</span><span class="w"> </span><span class="n">mag</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">sigma</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="n">sqrt</span><span class="p">(</span><span class="mf">-2.0</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="n">log</span><span class="p">(</span><span class="n">u1</span><span class="p">));</span>
   1529 <span class="w">    </span><span class="k">auto</span><span class="w"> </span><span class="n">z0</span><span class="w">  </span><span class="o">=</span><span class="w"> </span><span class="n">mag</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="n">cos</span><span class="p">(</span><span class="n">two_pi</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="n">u2</span><span class="p">)</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="n">mu</span><span class="p">;</span>
   1530 <span class="w">    </span><span class="k">auto</span><span class="w"> </span><span class="n">z1</span><span class="w">  </span><span class="o">=</span><span class="w"> </span><span class="n">mag</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="n">sin</span><span class="p">(</span><span class="n">two_pi</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="n">u2</span><span class="p">)</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="n">mu</span><span class="p">;</span>
   1531 
   1532 <span class="w">    </span><span class="k">return</span><span class="w"> </span><span class="n">std</span><span class="o">::</span><span class="n">make_pair</span><span class="p">(</span><span class="n">z0</span><span class="p">,</span><span class="w"> </span><span class="n">z1</span><span class="p">);</span>
   1533 <span class="p">}</span>
   1534 </pre></div>
   1535 <h2><span class="mw-headline" id="See_also">See also</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Box%E2%80%93Muller_transform&amp;action=edit&amp;section=6" title="Edit section: See also"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></h2>
   1536 <ul><li><a href="/wiki/Inverse_transform_sampling" title="Inverse transform sampling">Inverse transform sampling</a></li>
   1537 <li><a href="/wiki/Marsaglia_polar_method" title="Marsaglia polar method">Marsaglia polar method</a>, similar transform to Box–Muller, which uses Cartesian coordinates, instead of polar coordinates</li></ul>
   1538 <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=Box%E2%80%93Muller_transform&amp;action=edit&amp;section=7" title="Edit section: References"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></h2>
   1539 <ul><li><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="CITEREFHowesThomas2008" class="citation book cs1">Howes, Lee; Thomas, David (2008). <i>GPU Gems 3 - Efficient Random Number Generation and Application Using CUDA</i>. Pearson Education, Inc. <a href="/wiki/ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a>&#160;<a href="/wiki/Special:BookSources/978-0-321-51526-1" title="Special:BookSources/978-0-321-51526-1"><bdi>978-0-321-51526-1</bdi></a>.</cite><span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&amp;rft.genre=book&amp;rft.btitle=GPU+Gems+3+-+Efficient+Random+Number+Generation+and+Application+Using+CUDA&amp;rft.pub=Pearson+Education%2C+Inc.&amp;rft.date=2008&amp;rft.isbn=978-0-321-51526-1&amp;rft.aulast=Howes&amp;rft.aufirst=Lee&amp;rft.au=Thomas%2C+David&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3ABox%E2%80%93Muller+transform" class="Z3988"></span></li></ul>
   1540 <div class="mw-references-wrap"><ol class="references">
   1541 <li id="cite_note-1"><span class="mw-cite-backlink"><b><a href="#cite_ref-1">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1133582631"><cite id="CITEREFBoxMuller1958" class="citation journal cs1">Box, G. E. P.; Muller, Mervin E. (1958). <a rel="nofollow" class="external text" href="https://doi.org/10.1214%2Faoms%2F1177706645">"A Note on the Generation of Random Normal Deviates"</a>. <i>The Annals of Mathematical Statistics</i>. <b>29</b> (2): 610–611. <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.1214%2Faoms%2F1177706645">10.1214/aoms/1177706645</a></span>. <a href="/wiki/JSTOR_(identifier)" class="mw-redirect" title="JSTOR (identifier)">JSTOR</a>&#160;<a rel="nofollow" class="external text" href="https://www.jstor.org/stable/2237361">2237361</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=The+Annals+of+Mathematical+Statistics&amp;rft.atitle=A+Note+on+the+Generation+of+Random+Normal+Deviates&amp;rft.volume=29&amp;rft.issue=2&amp;rft.pages=610-611&amp;rft.date=1958&amp;rft_id=info%3Adoi%2F10.1214%2Faoms%2F1177706645&amp;rft_id=https%3A%2F%2Fwww.jstor.org%2Fstable%2F2237361%23id-name%3DJSTOR&amp;rft.aulast=Box&amp;rft.aufirst=G.+E.+P.&amp;rft.au=Muller%2C+Mervin+E.&amp;rft_id=https%3A%2F%2Fdoi.org%2F10.1214%252Faoms%252F1177706645&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3ABox%E2%80%93Muller+transform" class="Z3988"></span></span>
   1542 </li>
   1543 <li id="cite_note-2"><span class="mw-cite-backlink"><b><a href="#cite_ref-2">^</a></b></span> <span class="reference-text">Raymond E. A. C. Paley and Norbert Wiener <i>Fourier Transforms in the Complex Domain,</i> New York: American Mathematical Society (1934) §37.</span>
   1544 </li>
   1545 <li id="cite_note-3"><span class="mw-cite-backlink"><b><a href="#cite_ref-3">^</a></b></span> <span class="reference-text">Kloeden and Platen, <i>Numerical Solutions of Stochastic Differential Equations</i>, pp. 11–12</span>
   1546 </li>
   1547 <li id="cite_note-4"><span class="mw-cite-backlink"><b><a href="#cite_ref-4">^</a></b></span> <span class="reference-text"><a href="#CITEREFHowesThomas2008">Howes &amp; Thomas 2008</a>.</span>
   1548 </li>
   1549 <li id="cite_note-5"><span class="mw-cite-backlink"><b><a href="#cite_ref-5">^</a></b></span> <span class="reference-text">Sheldon Ross, <i>A First Course in Probability</i>, (2002), pp. 279–281</span>
   1550 </li>
   1551 <li id="cite_note-Bell68-6"><span class="mw-cite-backlink">^ <a href="#cite_ref-Bell68_6-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-Bell68_6-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="CITEREFBell1968" class="citation journal cs1">Bell, James R. (1968). <a rel="nofollow" class="external text" href="http://portal.acm.org/citation.cfm?doid=363397.363547">"Algorithm 334: Normal random deviates"</a>. <i>Communications of the ACM</i>. <b>11</b> (7): 498. <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.1145%2F363397.363547">10.1145/363397.363547</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=Communications+of+the+ACM&amp;rft.atitle=Algorithm+334%3A+Normal+random+deviates&amp;rft.volume=11&amp;rft.issue=7&amp;rft.pages=498&amp;rft.date=1968&amp;rft_id=info%3Adoi%2F10.1145%2F363397.363547&amp;rft.aulast=Bell&amp;rft.aufirst=James+R.&amp;rft_id=http%3A%2F%2Fportal.acm.org%2Fcitation.cfm%3Fdoid%3D363397.363547&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3ABox%E2%80%93Muller+transform" class="Z3988"></span></span>
   1552 </li>
   1553 <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 id="CITEREFKnop1969" class="citation journal cs1">Knop, R. (1969). <a rel="nofollow" class="external text" href="http://portal.acm.org/citation.cfm?doid=362946.362996">"Remark on algorithm 334 &#91;G5&#93;: Normal random deviates"</a>. <i>Communications of the ACM</i>. <b>12</b> (5): 281. <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.1145%2F362946.362996">10.1145/362946.362996</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=Communications+of+the+ACM&amp;rft.atitle=Remark+on+algorithm+334+%26%2391%3BG5%26%2393%3B%3A+Normal+random+deviates&amp;rft.volume=12&amp;rft.issue=5&amp;rft.pages=281&amp;rft.date=1969&amp;rft_id=info%3Adoi%2F10.1145%2F362946.362996&amp;rft.aulast=Knop&amp;rft.aufirst=R.&amp;rft_id=http%3A%2F%2Fportal.acm.org%2Fcitation.cfm%3Fdoid%3D362946.362996&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3ABox%E2%80%93Muller+transform" class="Z3988"></span></span>
   1554 </li>
   1555 <li id="cite_note-8"><span class="mw-cite-backlink"><b><a href="#cite_ref-8">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1133582631"><cite id="CITEREFKnuth1998" class="citation book cs1"><a href="/wiki/Donald_Knuth" title="Donald Knuth">Knuth, Donald</a> (1998). <i>The Art of Computer Programming: Volume 2: Seminumerical Algorithms</i>. p.&#160;122. <a href="/wiki/ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a>&#160;<a href="/wiki/Special:BookSources/0-201-89684-2" title="Special:BookSources/0-201-89684-2"><bdi>0-201-89684-2</bdi></a>.</cite><span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&amp;rft.genre=book&amp;rft.btitle=The+Art+of+Computer+Programming%3A+Volume+2%3A+Seminumerical+Algorithms&amp;rft.pages=122&amp;rft.date=1998&amp;rft.isbn=0-201-89684-2&amp;rft.aulast=Knuth&amp;rft.aufirst=Donald&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3ABox%E2%80%93Muller+transform" class="Z3988"></span></span>
   1556 </li>
   1557 <li id="cite_note-Carter-9"><span class="mw-cite-backlink"><b><a href="#cite_ref-Carter_9-0">^</a></b></span> <span class="reference-text"><a rel="nofollow" class="external text" href="ftp://ftp.taygeta.com/pub/publications/randnum.tar.Z">Everett F. Carter, Jr., <i>The Generation and Application of Random Numbers</i>, Forth Dimensions (1994), Vol. 16, No. 1 &amp; 2.</a></span>
   1558 </li>
   1559 <li id="cite_note-10"><span class="mw-cite-backlink"><b><a href="#cite_ref-10">^</a></b></span> <span class="reference-text">The evaluation of 2<span class="texhtml mvar" style="font-style:italic;">π</span><i>U</i><sub>1</sub> is counted as one multiplication because the value of 2<span class="texhtml mvar" style="font-style:italic;">π</span> can be computed in advance and used repeatedly.</span>
   1560 </li>
   1561 </ol></div>
   1562 <h2><span class="mw-headline" id="External_links">External links</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Box%E2%80%93Muller_transform&amp;action=edit&amp;section=8" title="Edit section: External links"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></h2>
   1563 <ul><li><span class="citation mathworld" id="Reference-Mathworld-Box-Muller_Transformation"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1133582631"><cite id="CITEREFWeisstein" class="citation web cs1"><a href="/wiki/Eric_W._Weisstein" title="Eric W. Weisstein">Weisstein, Eric W.</a> <a rel="nofollow" class="external text" href="https://mathworld.wolfram.com/Box-MullerTransformation.html">"Box-Muller Transformation"</a>. <i><a href="/wiki/MathWorld" title="MathWorld">MathWorld</a></i>.</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=MathWorld&amp;rft.atitle=Box-Muller+Transformation&amp;rft.au=Weisstein%2C+Eric+W.&amp;rft_id=https%3A%2F%2Fmathworld.wolfram.com%2FBox-MullerTransformation.html&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3ABox%E2%80%93Muller+transform" class="Z3988"></span></span></li>
   1564 <li><a rel="nofollow" class="external text" href="https://cockrum.net/code.html#TrueRNG_gaussian">How to Convert a Uniform Distribution to a Gaussian Distribution (C Code)</a></li></ul>
   1565 <!-- 
   1566 NewPP limit report
   1567 Parsed by mw1476
   1568 Cached time: 20231125182527
   1569 Cache expiry: 1814400
   1570 Reduced expiry: false
   1571 Complications: [vary‐revision‐sha1, show‐toc]
   1572 CPU time usage: 0.237 seconds
   1573 Real time usage: 0.342 seconds
   1574 Preprocessor visited node count: 824/1000000
   1575 Post‐expand include size: 13234/2097152 bytes
   1576 Template argument size: 764/2097152 bytes
   1577 Highest expansion depth: 8/100
   1578 Expensive parser function count: 2/500
   1579 Unstrip recursion depth: 1/20
   1580 Unstrip post‐expand size: 25372/5000000 bytes
   1581 Lua time usage: 0.118/10.000 seconds
   1582 Lua memory usage: 4618326/52428800 bytes
   1583 Number of Wikibase entities loaded: 0/400
   1584 -->
   1585 <!--
   1586 Transclusion expansion time report (%,ms,calls,template)
   1587 100.00%  216.097      1 -total
   1588  32.23%   69.645      2 Template:Cite_book
   1589  24.98%   53.988      1 Template:Short_description
   1590  14.77%   31.908      2 Template:Pagetype
   1591  11.41%   24.654      1 Template:Harvnb
   1592   8.98%   19.401      1 Template:Main
   1593   7.98%   17.244      3 Template:Cite_journal
   1594   6.22%   13.445      1 Template:MathWorld
   1595   5.29%   11.426      2 Template:Main_other
   1596   4.53%    9.783      1 Template:SDcat
   1597 -->
   1598 
   1599 <!-- Saved in parser cache with key enwiki:pcache:idhash:60758-0!canonical and timestamp 20231125182527 and revision id 1184897234. Rendering was triggered because: page-view
   1600  -->
   1601 </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>
   1602 <div class="printfooter" data-nosnippet="">Retrieved from "<a dir="ltr" href="https://en.wikipedia.org/w/index.php?title=Box–Muller_transform&amp;oldid=1184897234">https://en.wikipedia.org/w/index.php?title=Box–Muller_transform&amp;oldid=1184897234</a>"</div></div>
   1603 					<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">Categories</a>: <ul><li><a href="/wiki/Category:Transforms" title="Category:Transforms">Transforms</a></li><li><a href="/wiki/Category:Non-uniform_random_numbers" title="Category:Non-uniform random numbers">Non-uniform random numbers</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_matches_Wikidata" title="Category:Short description matches Wikidata">Short description matches Wikidata</a></li><li><a href="/wiki/Category:Articles_with_example_C%2B%2B_code" title="Category:Articles with example C++ code">Articles with example C++ code</a></li></ul></div></div>
   1604 				</div>
   1605 			</main>
   1606 			
   1607 		</div>
   1608 		<div class="mw-footer-container">
   1609 			
   1610 <footer id="footer" class="mw-footer" role="contentinfo" >
   1611 	<ul id="footer-info">
   1612 	<li id="footer-info-lastmod"> This page was last edited on 13 November 2023, at 08:41<span class="anonymous-show">&#160;(UTC)</span>.</li>
   1613 	<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>;
   1614 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>
   1615 </ul>
   1616 
   1617 	<ul id="footer-places">
   1618 	<li id="footer-places-privacy"><a href="https://foundation.wikimedia.org/wiki/Special:MyLanguage/Policy:Privacy_policy">Privacy policy</a></li>
   1619 	<li id="footer-places-about"><a href="/wiki/Wikipedia:About">About Wikipedia</a></li>
   1620 	<li id="footer-places-disclaimers"><a href="/wiki/Wikipedia:General_disclaimer">Disclaimers</a></li>
   1621 	<li id="footer-places-contact"><a href="//en.wikipedia.org/wiki/Wikipedia:Contact_us">Contact Wikipedia</a></li>
   1622 	<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>
   1623 	<li id="footer-places-developers"><a href="https://developer.wikimedia.org">Developers</a></li>
   1624 	<li id="footer-places-statslink"><a href="https://stats.wikimedia.org/#/en.wikipedia.org">Statistics</a></li>
   1625 	<li id="footer-places-cookiestatement"><a href="https://foundation.wikimedia.org/wiki/Special:MyLanguage/Policy:Cookie_statement">Cookie statement</a></li>
   1626 	<li id="footer-places-mobileview"><a href="//en.m.wikipedia.org/w/index.php?title=Box%E2%80%93Muller_transform&amp;mobileaction=toggle_view_mobile" class="noprint stopMobileRedirectToggle">Mobile view</a></li>
   1627 </ul>
   1628 
   1629 	<ul id="footer-icons" class="noprint">
   1630 	<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>
   1631 	<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>
   1632 </ul>
   1633 
   1634 </footer>
   1635 
   1636 		</div>
   1637 	</div> 
   1638 </div> 
   1639 <div class="vector-settings" id="p-dock-bottom">
   1640 	<ul>
   1641 		<li>
   1642 		
   1643 		<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>
   1644 
   1645 <span>Toggle limited content width</span>
   1646 </button>
   1647 </li>
   1648 	</ul>
   1649 </div>
   1650 <script>(RLQ=window.RLQ||[]).push(function(){mw.config.set({"wgHostname":"mw-web.eqiad.main-7bbb9c7bbf-t8k24","wgBackendResponseTime":128,"wgPageParseReport":{"limitreport":{"cputime":"0.237","walltime":"0.342","ppvisitednodes":{"value":824,"limit":1000000},"postexpandincludesize":{"value":13234,"limit":2097152},"templateargumentsize":{"value":764,"limit":2097152},"expansiondepth":{"value":8,"limit":100},"expensivefunctioncount":{"value":2,"limit":500},"unstrip-depth":{"value":1,"limit":20},"unstrip-size":{"value":25372,"limit":5000000},"entityaccesscount":{"value":0,"limit":400},"timingprofile":["100.00%  216.097      1 -total"," 32.23%   69.645      2 Template:Cite_book"," 24.98%   53.988      1 Template:Short_description"," 14.77%   31.908      2 Template:Pagetype"," 11.41%   24.654      1 Template:Harvnb","  8.98%   19.401      1 Template:Main","  7.98%   17.244      3 Template:Cite_journal","  6.22%   13.445      1 Template:MathWorld","  5.29%   11.426      2 Template:Main_other","  4.53%    9.783      1 Template:SDcat"]},"scribunto":{"limitreport-timeusage":{"value":"0.118","limit":"10.000"},"limitreport-memusage":{"value":4618326,"limit":52428800},"limitreport-logs":"anchor_id_list = table#1 {\n    [\"CITEREFBell1968\"] = 1,\n    [\"CITEREFBoxMuller1958\"] = 1,\n    [\"CITEREFHowesThomas2008\"] = 1,\n    [\"CITEREFKnop1969\"] = 1,\n    [\"CITEREFKnuth1998\"] = 1,\n}\ntemplate_list = table#1 {\n    [\"=\"] = 4,\n    [\"Cite book\"] = 2,\n    [\"Cite journal\"] = 3,\n    [\"DEFAULTSORT:Box-Muller Transform\"] = 1,\n    [\"Harvnb\"] = 1,\n    [\"Main\"] = 1,\n    [\"MathWorld\"] = 1,\n    [\"Nowrap\"] = 7,\n    [\"Pi\"] = 5,\n    [\"Short description\"] = 1,\n}\narticle_whitelist = table#1 {\n}\n"},"cachereport":{"origin":"mw1476","timestamp":"20231125182527","ttl":1814400,"transientcontent":false}}});});</script>
   1651 <script type="application/ld+json">{"@context":"https:\/\/schema.org","@type":"Article","name":"Box\u2013Muller transform","url":"https:\/\/en.wikipedia.org\/wiki\/Box%E2%80%93Muller_transform","sameAs":"http:\/\/www.wikidata.org\/entity\/Q895514","mainEntity":"http:\/\/www.wikidata.org\/entity\/Q895514","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":"2002-07-06T15:49:41Z","dateModified":"2023-11-13T08:41:28Z","image":"https:\/\/upload.wikimedia.org\/wikipedia\/commons\/1\/1f\/Box-Muller_transform_visualisation.svg","headline":"Statistical transform"}</script>
   1652 </body>
   1653 </html>