Add tasks for all the new languages
This commit is contained in:
parent
9dc3c2bb62
commit
bba7bfd280
13208 changed files with 134745 additions and 0 deletions
35
Task/Random-numbers/ERRE/random-numbers.erre
Normal file
35
Task/Random-numbers/ERRE/random-numbers.erre
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
PROGRAM DISTRIBUTION
|
||||
|
||||
!
|
||||
! for rosettacode.org
|
||||
!
|
||||
|
||||
! formulas taken from TI-59 Master Library manual
|
||||
|
||||
CONST NUM_ITEM=1000
|
||||
|
||||
!VAR SUMX#,SUMX2#,R1#,R2#,Z#,I%
|
||||
|
||||
DIM A#[1000]
|
||||
|
||||
BEGIN
|
||||
! seeds random number generator with system time
|
||||
RANDOMIZE(TIMER)
|
||||
|
||||
PRINT(CHR$(12);) !CLS
|
||||
SUMX#=0 SUMX2#=0
|
||||
|
||||
FOR I%=1 TO NUM_ITEM DO
|
||||
R1#=RND(1) R2#=RND(1)
|
||||
Z#=SQR(-2*LOG(R1#))*COS(2*π*R2#)
|
||||
A#[I%]=Z#/2+1 ! I want a normal distribution with
|
||||
! mean=1 and std.dev=0.5
|
||||
SUMX#+=A#[I%] SUMX2#+=A#[I%]*A#[I%]
|
||||
END FOR
|
||||
|
||||
Z#=SUMX#/NUM_ITEM
|
||||
|
||||
PRINT("Average is";Z#)
|
||||
PRINT("Standard dev. is";SQR(SUMX2#/NUM_ITEM-Z#*Z#))
|
||||
|
||||
END PROGRAM
|
||||
Loading…
Add table
Add a link
Reference in a new issue