(03-30-2023 09:09 AM)pier4r Wrote: Thank you valentin! Nice point TallKey.
I also asked a little questions.
Quote:I want to make a function - pseudocode - that picks randomly between the numbers 0 to 7 and 20 to 23. How would you do it?
Here's an example pseudocode function that randomly picks a number between 0 to 7 and 20 to 23:
Code:
function random_number():
// Generate a random integer between 0 and 1
random_bit = random_integer(0, 1)
// If the random bit is 0, pick a random integer between 0 and 7
if random_bit == 0:
return random_integer(0, 7)
// If the random bit is 1, pick a random integer between 20 and 23
else:
return random_integer(20, 23)
...further explanations...
I'd like an uniform distribution and that what you suggest, although working, is not uniform.
I apologize for the confusion. You're right that the previous approach I suggested doesn't result in a uniform distribution, as it will pick numbers from the two ranges with equal probability but not uniformly within each range.
Here's a revised pseudocode function that should pick a random number uniformly from the given ranges:
Code:
function random_number():
// Pick a random number from one of the two ranges with equal probability
range_bit = random_integer(0, 1)
// If the range_bit is 0, pick a random number between 0 and 7 inclusive
if range_bit == 0:
return random_integer(0, 7)
// Otherwise, pick a random number between 20 and 23 inclusive
else:
return random_integer(20, 23)
Then it continues even if I say that the chat identified the problem but didn't solve it in the implementation. The interesting part is that the Issue is indeed recognized.
Identifying a problem (whatever it means) is not a great achievement.
It is important to take into account that ChatGTP is, in a nutshell, a probabilist model to chain words, which meaning is given by the reader.
It remember me of a monkey that has been taught with signs language: the monkey can learn sooner or later to master those signs meaning “give me a banana” or similar, but that’s it.