RE: Random Numbers - Pete - 08-28-2025
...And Schrodinger's cat is always alive in some other universe.
Pete
RE: Random Numbers - madscijr - 08-30-2025
(08-28-2025, 07:06 PM)Herve Wrote: Hi,
A few years ago, I needed to obtain a long series of truly randomized numbers; I used the tools offered by https://random.org. If you are not familiar with it, I encourage you to rush to their site. Interesting site - who knew? You did! Thanks!
RE: Random Numbers - madscijr - 08-30-2025
(08-28-2025, 07:47 PM)Pete Wrote: ...And Schrodinger's cat is always alive in some other universe.
Pete  Schrodinger's cat solved our rodent problem but then it peed outside the litter box!
It giveth and it taketh away!
RE: Random Numbers - Magdha - 10-18-2025
Some time ago I thought that I would amuse myself by writing a program to generate quasi-random numbers. And the interest would be to see if the 'randomness' would be anything like RND. The attach code is what I came up with. I knew that code-produced 'random number' generation had something to do with very large number manipulations. Steve McNeill has shown how the QB64 RND function works. The details of my attempt are not worth exploring here, and the only point of interest is how 'random' my numbers were. The image shows a distribution of the output and the superficial analysis suggests the numbers are reasonably random, and the function worked well when replacing RND in an actual program. A minor ( ) down-side is that this function is over 1000 times slower than RND - but I was pleased! (And I suppose that we have all attempted something similar at some idle moment).
Code: (Select All)
' Attempt to create a quasi-random number sequence using huge number multiplication mathematics 15/11/23
' When used instead of RND in an actual program
' this function works properly but is much, much slower - completely as expected.
' A success!
' Obviously BigNumberRND1 is quicker than BigNumberRND
CONST False = 0, True = NOT False '!!! Remove this if used in a program which has this already
PRINT BigNumberRND, BigNumberRND1 '!!! Remove this if used in a program
END '!!! Remove this if used in a program
FUNCTION BigNumberRND
'Function generates huge numbers (18-19 figures), selects one digit
'And strings six sequential numbers
'And divides by 1e6 to get a number 0 - 0.999999
STATIC Initi%%, HugeNo~&&, RanNo%%
IF NOT Initi%% THEN
Initi%% = True
Timely& = INT(100 * TIMER)
T$ = _TRIM$(STR$(Timely&))
RanNo%% = VAL(MID$(T$, 2, 1)) '9
'Get Primes
Index%% = 2
N%% = 1
Starter~&& = 1
WHILE N%% <= 9
Index%% = Index%% + 1
IsPrime%% = True
K%% = 2
WHILE IsPrime%% AND K%% < Index%%
IF Index%% / K%% = Index%% \ K%% THEN IsPrime%% = False
K%% = K%% + 1
WEND
IF IsPrime%% THEN
Starter~&& = Starter~&& * Index%%
IF N%% = 8 THEN HugeNo~&& = Starter~&& + Timely&
IF N%% = 9 THEN HugeNo~&& = HugeNo~&& * Starter~&&
N%% = N%% + 1
END IF
WEND
END IF
RanChr$ = ""
FOR N%% = 1 TO 6
BigString$ = _TRIM$(STR$(HugeNo~&&))
RanString$ = MID$(BigString$, 5 + RanNo%%, 1)
RanChr$ = RanChr$ + RanString$
RanNo%% = VAL(RanString$)
Biggy%% = False
J%% = 1
WHILE NOT Biggy%%
IF VAL(MID$(BigString$, J%%, 1)) >= 2 THEN
FirstString$ = MID$(BigString$, J%%, 9)
Biggy%% = True
END IF
J%% = J%% + 1
WEND
Biggy%% = False
J%% = LEN(BigString$) - 9
WHILE NOT Biggy%%
IF VAL(MID$(BigString$, J%%, 1)) >= 2 THEN
SecondString$ = MID$(BigString$, J%%, 9)
Biggy%% = True
END IF
J%% = J%% - 1
WEND
HugeNo~&& = VAL(FirstString$) * VAL(SecondString$)
NEXT N%%
BigNumberRND = VAL(RanChr$) / 1E6
END FUNCTION
FUNCTION BigNumberRND1
'Function generates huge numbers (18-19 figures), selects six sequential digits
'And divides by 1e6 to get a number 0 - 0.999999
STATIC Initi%%, HugeNo~&&, RanNo%%
IF NOT Initi%% THEN
Initi%% = True
Timely& = INT(100 * TIMER)
T$ = _TRIM$(STR$(Timely&))
RanNo%% = VAL(MID$(T$, 2, 1)) '9
'Get Primes
Index%% = 2
N%% = 1
Starter~&& = 1
WHILE N%% <= 9
Index%% = Index%% + 1
IsPrime%% = True
K%% = 2
WHILE IsPrime%% AND K%% < Index%%
IF Index%% / K%% = Index%% \ K%% THEN IsPrime%% = False
K%% = K%% + 1
WEND
IF IsPrime%% THEN
Starter~&& = Starter~&& * Index%%
IF N%% = 8 THEN HugeNo~&& = Starter~&& + Timely&
IF N%% = 9 THEN HugeNo~&& = HugeNo~&& * Starter~&&
N%% = N%% + 1
END IF
WEND
END IF
BigString$ = _TRIM$(STR$(HugeNo~&&))
RanString$ = MID$(BigString$, 5 + RanNo%%, 1)
RNDTemp! = VAL(MID$(BigString$, 1 + RanNo%%, 6)) / 1E6
RanNo%% = VAL(RanString$)
Biggy%% = False
J%% = 1
WHILE NOT Biggy%%
IF VAL(MID$(BigString$, J%%, 1)) >= 2 THEN
FirstString$ = MID$(BigString$, J%%, 9)
Biggy%% = True
END IF
J%% = J%% + 1
WEND
Biggy%% = False
J%% = LEN(BigString$) - 9
WHILE NOT Biggy%%
IF VAL(MID$(BigString$, J%%, 1)) >= 2 THEN
SecondString$ = MID$(BigString$, J%%, 9)
Biggy%% = True
END IF
J%% = J%% - 1
WEND
HugeNo~&& = VAL(FirstString$) * VAL(SecondString$)
BigNumberRND1 = RNDTemp!
END FUNCTION
RE: Random Numbers - hsiangch_ong - 10-19-2025
i'm learning common lisp.
where i discovered something. the great experts at programming. don't know how to make "platform independent."
so be glad basic has randomize timer. that's all folks.
RE: Random Numbers - dano - 10-19-2025
Cloudflare uses lava 100 lamps to generate random numbers for use in cryptogrophy:
https://blog.cloudflare.com/randomness-101-lavarand-in-production/
Pretty neat stuff.
RE: Random Numbers - Pete - 10-19-2025
It only works because nobody would ever want to steal anything from anybody who who owned a lava lamp, least of all 100 of them!
Pete
- The 70's called and they say they're doing fine without me!
|