Opened 14 years ago

Closed 14 years ago

Last modified 14 years ago

#2380 closed defect (fixed)

TA random not including max

Reported by: walter Owned by: walter
Priority: Unspecified by Maintainer Milestone: Unspecified
Component: Turtleart Version: Unspecified
Severity: Unspecified Keywords:
Cc: tonyforster Distribution/OS: Unspecified
Bug Status: Unconfirmed

Description

e.g., random (1,10) never returns 10

More details in email exchange between Daniel Ajoy and Tony Forster:

Hoy noté que la ficha "aleatorio min max" nunca devuelve el número máximo.

Por ejemplo, imagen adjunta.

Me pareció poco intuitivo... pero qué piensan los demás.

Daniel

¿Es esto un error, debe volver random real 1-1,9999... en lugar de una integer
?

Is this an error, should random return a real 1 - 1.9999... instead of an integer
?

Tony

I personally think that MAX should be included as a possible output of RANDOM. And that RANDOM should keep returning just integers.

In Logo, RANDOM only receives 1 input:

random Number

Reports a random non-negative integer (including 0) less than number.

So you wouldn't need the MIN, MAX labels

Getting negatives and fractions is a lesson in manipulating random variables with subtraction and division ... but it is not as low-floor as using MIN, MAX.

---

Yo personalmente creo que MAX debe ser incluido como posible valor de ALEATORIO (También me parece que la traducción de RANDOM debe ser AZAR, para mantener compatibilidad con Logo, por lo menos en nombre). Y que ALEATORIO debe seguir reportando enteros.

En Logo, AZAR solamente recibe 1 valor:

AZAR Numero

Reporta un entero no negativo al azar, menor que el número dado.

Ejemplo:

repite 10 [escribe azar 2]
1
1
0
0
0
0
1
1
1
1

El obtener negativos y fracciones al azar sirve de lección de manipulación de variables aleatorias mediante resta y división ... pero la necesidad de esta lección convierte a AZAR en una comando de no-tan-bajo-piso, ALEATORIO MIN MAX es de más bajo piso.

Daniel

Change History (3)

comment:1 Changed 14 years ago by walter

  • Resolution set to fixed
  • Status changed from new to closed

Turns out that this is due to a rounding error. This patch fixes it:

http://git.sugarlabs.org/projects/turtleart/repos/mainline/commits/d2a60c4ae61bef176f7ff92b6ff36c2e33ebf37a

Patch will be included in v99.

comment:3 Changed 14 years ago by tonyforster

  • Cc tonyforster added
Note: See TracTickets for help on using tickets.