English
Source / code snippets

Gaußverteilte Zufallswerte: Box-Muller Algorithmus

 

p.specht

Zufallsgeneratoren for Normalverteilung (cue "Gaußsche Glockenkurve") there some. One langsameres, but for qualitative right good take action having Box and Muller 1958 pictured:
Window Title "Box-Muller: Normalverteilte Zufallszahlen, zB. with µ=0, "+chr $(240)+"=1"
'(CL) jan. 2012 by P.woodpecker, Demoware without jegliche Gewähr!
'{ Win7 Printbereich arrange. who no Win7 has: CLS reicht!
Font 2:randomize:cls rnd(8^8)
var xr%=(%WinRight- %WinLeft-width(%Hwnd))+1
var yr%=(%WinBottom-%WinTop-height(%Hwnd))+1
var u%=640:var v%=480:var xf!=0.797:var yf!=0.72
Window (u%-xr%)*xf!+xr%,(v%-yr%)*yf!+yr%
SetWindowPos %HWnd=(%maxx-u%)/2,((%maxy-v%)/2) - u%,v%
'}
set("decimals",16)
var pi2!= 6.283185307179586476925286766559
var fa! = 1/sqrt(pi2!)
declare r1!,r2!,z1!,z2!,s2!,s3!,n&
declare mw!,vz!,sa!,my$,my!,si5!,sigma!,s$
print " Wieviele Testzahlen go needed?: ";:input n&:case n&=0:n&=10000
print " where lying the reale story?: ";:input my$:my!=val(my$)
print "\n into undertow. Sigmagrenzen entrapments The folg.%-Sätze the values:"
print " 1"+chr $(240)+":68.27% 2:95.45% 3:99.73% 4:99.9937% 5:99.9999%"
print "\n difference Mittelpunkt to that worth, the on the weitesten lane lying,"
print " [no unplausibler Ausreisser!]  (5"+chr $(240)+") ?: ";
input si5!
sigma!=abs(si5!)/5
s$="":clearclip
r1!=rnd()' gleichverteilt

Whileloop n&

    r2!=rnd()
    s2!=sqrt(-2*ln(r1!))
    's3!=pi2!*r2!
    z1! = s2! * cos(pi2!*r2!)'..cos(s3!) ' standard-normalverteilt
    'z2! = s2! * sin(s3!)
    s$=s$+st$(z1!*sigma!+my!)
    casenot &Loop=n&:s$=s$+","
    mw!=mw!+z1!
    vz!=vz!+sqr(z1!)
    r1!=r2!

EndWhile

beep
putclip s$
print "\n you've now "+st$(n&)+" Testwerte in the filing!"
mw!=mw!/n&
vz!=(vz!-mw!*mw!)/(n&-1)
sa!=sqrt(vz!)
print "\n control:  "
print " story: ";mw!*sigma!+my!
'print " SP-Varianz: ";vz!
print " SP-Varianz: ";(sa!*sigma!)^2
print " stood.Abw.: ";sa!*sigma!
WaitInput
End
 
XProfan 11
Computer: Gerät, daß es in Mikrosekunden erlaubt, 50.000 Fehler zu machen, zB 'daß' statt 'das'...
04/25/21  
 



Zum Quelltext


Topictitle, max. 100 characters.
 

Systemprofile:

no Systemprofil laid out. [anlegen]

XProfan:

 Posting  Font  Smilies  ▼ 

Please register circa a Posting To verfassen.
 

Topic-Options

559 Views

Untitledvor 0 min.
N.Art07/21/22
Ernst07/21/21
Glubbfan06/19/21
Uwe ''Pascal'' Niemeier06/13/21
More...

Themeninformationen

this Topic has 1 subscriber:

p.specht (1x)


Admins  |  AGB  |  Applications  |  Authors  |  Chat  |  Privacy Policy  |  Download  |  Entrance  |  Help  |  Merchantportal  |  Imprint  |  Mart  |  Interfaces  |  SDK  |  Services  |  Games  |  Search  |  Support

One proposition all XProfan, The there's!


My XProfan
Private Messages
Own Storage Forum
Topics-Remember-List
Own Posts
Own Topics
Clipboard
Log off
 Deutsch English Français Español Italia
Translations

Privacy Policy


we use Cookies only as Session-Cookies because of the technical necessity and with us there no Cookies of Drittanbietern.

If you here on our Website click or navigate, stimmst You ours registration of Information in our Cookies on XProfan.Net To.

further Information To our Cookies and moreover, How You The control above keep, find You in ours nachfolgenden Datenschutzerklärung.


all rightDatenschutzerklärung
i want none Cookie