Understanding Random Behavior

goldenj shared this question 1 year ago
Answered

So I was just making a piece for fun, with the idea that I'd build a grid by selecting for each integer pair a random quarter of the circle with radius 1 or edge of a square of width 1. I built an 8 member list, then tried to make a command like

Sequence(Sequence(Translate(RandomElement(l1), (i, j)), i, 1, n), j, 1, n)

It would only select a variety of segments or arcs but never a mix. About half undefined elements. Hmm. So I tried building an nxn matrix of RandomBetween(1,8) and selecting

Sequence(Sequence(Translate(Element(l1, Element(m4, i, j)), (i, j)), i, 1, n), j, 1, n)

with the same result. So I made a list of lists {{arc1, arc2, ...},{seg1,seg2,...}} and

Sequence(Sequence(Translate(RandomElement(RandomElement(l1)), (i, j)), i, 1, n), j, 1, n)

and got the same result.

It doesn't matter because this was just for fun, but can anyone help me understand what's going on?

ps: when I tried translating the whole list to each (i,j) it worked.

Comments (14)

photo
1

It's not a problem of random. It's a problem of addressing the 2 dimensional list.

====================================================

l3 = {{<conic>,....<conic>}, {<segment>, ......<segment>}}

is a 2 dimensional list

.

for circles:

Sequence(Sequence(Translate(RandomElement(Element(l3, 1)), (i, j)), i, 1, n), j, 1, n)

.

for segments

Sequence(Sequence(Translate(RandomElement(Element(l3, 2)), (i, j)), i, 1, n), j, 1, n)

.

Note: circles and segments must be in separated Sequence() because a Sequence() [and also Zip()] can have only 1 object-type as output.

photo
1

I tried them all in one dimensional list to no avail as a first try. And even as a 2D list, why wouldn't RandomElement(RandomElement(l3)) work to make a mix?

photo
1

Note my note above.

"RandomElement(RandomElement(l3))" broke the rule in the note.

Not all is documented in GGB; but sure nothing what GGB does when a rule is broken.

I guess that at the time of precompiling (open file?) ggb decides which object type is to apply.

.

Open the attached file (test-version 0) 10 times: after opening one (1) random object type appears, but after each update-construction always the same as before. Also notice the "?" in the generated list l4. I think these are the random elements that broken the rule in my note above.

photo
1

https://wiki.geogebra.org/e...

All elements in the list must be of the same type.

photo
1

So why didn't the random number 1-8 matrix approach work? Do lists have to be all the same type always?

photo
1

Yes. You could try using CircumcircularArc(A, (A+B)/2, B) as a "fake" segment

photo
1

Okay, 2nd attempt. Made a tool to make squircles (squares with circular arc corners) given a point and two numbers. It works on individual points, but when I call it within sequence I only get the first of the 8 geometric objects in the command. Is there any workaround? Do I have to call 8 different sequence commands? Just 2 - one for segments, one for arcs?

Again, just for fun, but I want to understand.

photo
photo
1

yo creo que lo más simple es crear tres listas: lista de arcos, lista de segmentos, lista de booleanos

entonces se eligen aleatoriamente un arco, un segmento y un booleano para cada punto y se muestra el arco o el segmento segun el valor del booleano

photo
1

¡Buen idea! Lo voy a probar.

photo
1

ya he probado en este rato

photo
photo
1

he intentado el truco de Michael y he encontrado un bug en la traslacion de circumcirculararc() definidos a partir de puntos especificados mediante coordenadas dentro de la instruccion

si los puntos dentro del parentesis se especifican mediante coordenadas y no como nombres de puntos la traslacion no es correcta

Files: foro.ggb
photo
1

Fun thread to read - really cool result!

photo
2

I used parametrics to have your set be all one object type :

https://www.geogebra.org/m/pxu3ddqj

photo
2

fun is the favorite of mathematicians

/B0JD2Iiw7GknAAAAAElFTkSuQmCC

© 2020 International GeoGebra Institute