tasks a-s
This commit is contained in:
parent
47bf37c096
commit
b83f433714
12433 changed files with 156208 additions and 123 deletions
18
Task/Random-numbers/PureBasic/random-numbers.purebasic
Normal file
18
Task/Random-numbers/PureBasic/random-numbers.purebasic
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
Procedure.f RandomNormal()
|
||||
; This procedure can return any real number.
|
||||
Protected.f x1, x2
|
||||
|
||||
; random numbers from the open interval ]0, 1[
|
||||
x1 = (Random(999998)+1) / 1000000 ; must be > 0 because of Log(x1)
|
||||
x2 = (Random(999998)+1) / 1000000
|
||||
|
||||
ProcedureReturn Sqr(-2*Log(x1)) * Cos(2*#PI*x2)
|
||||
EndProcedure
|
||||
|
||||
|
||||
Define i, n=1000
|
||||
|
||||
Dim a.q(n-1)
|
||||
For i = 0 To n-1
|
||||
a(i) = 1 + 0.5 * RandomNormal()
|
||||
Next
|
||||
Loading…
Add table
Add a link
Reference in a new issue