Properties
Similar Topics
Statistics
Comments
12
Participants
5
Subscribers
0
Votes
2
Views
1401
Share
problems in generating a list with random() function
Answered
I'm trying to create an animation to show how to use Monte Carlo method to aproximate pi (3.14 ...).
For that, I'm using something like
abcissa = Sequence[random(), i, 1, n] (n is an integer slider)
but all the elements of that list are equal! Shouldn't every occurrance of random() function produce a (probably) different value?
Please see file I've attached.
 GeoGebra
 Help
 Partners

Contact us
 Feedback & Questions
 This email address is being protected from spambots. You need JavaScript enabled to view it.
 +43 677 6137 2693
© 2019 International GeoGebra Institute
Hi Carlos
I think that this file that I translated to Portuguese is written by Daniel Mentrard . Maybe this is what you want.
Daniel Mentrard:
http://dmentrard.free.fr/GE...
https://ggbm.at/533677
(open with prerelease)
Ola Carlos ...
well, as I opened you file i had the same problem. So I tried to rebuild the construction at my own.
Instead of n as variable for the number of points I took 20 and did it in the same way as you did it. Every works fine and I had 20 different point.
So I wanted to change it to use n. I created a number n = 50 and changed the definition of the first Sequence, and then the fault was there! Every randomnumber in each List was the same. But the two lists where different.
The same problem came up, when I wanted to change my (different) points by entering the command to build the list of points again:
Punkte=Folge[(Element[xWert,i],Element[yWert,i]),i,1,20]
in Englisch: Points= Sequence[(Element[xValue,i],Element[yValue,i]),i,1,20]
Same problem, every list had only one random number! That is a bug!
Btw ... it was not important, if I use random() or the new command Random[number,number].
Regards, Birgit.
hello
there is many files uploaded at GUM with random list of points
eg: my caleidoscope, dados2, sierpe
if you define abcissa = Sequence[random()+0*a, i, 1, n] been "a" a slider and you move the slider "a" the list of points are updated
about montecarlo you can see this
http://www.geogebra.org/for...
now it is very easy with spreadsheet but i like can do it in 3.0 version
saludos
Okay ...
you definition works fine, even with using n as an variabel. But as soon as I make n visible to get a slider, the behaviour is as I described!
Other trial. The sliders are visible before I created to list of points. Everythink okay until I moved one of the sliders!
I cant explain why this happens. To add a file is not useful, because after reloading my MonteCarloFile, there is only one point.
Birgit
hello
i have tried P=sequence[(random(),random()+0 n),i,1,n] (i use this form ever) and it work
saludos
:laughing: I'm the best tester ever , because I can crash everything ... :smiling_imp:
Okay mathmagic ... your idea works fine. I had a slider and got masses of points. I used up to 500 and everything works fine.
For the MonteCarloMethod I need to know how far are the points from the middle of the Circle A(0.5,0.5), so I used the command:
P_E=Sequence[Length[Element[P,i]A],i,1,n]
THen I wanted to move the slider n: At first, it took a long time before anything happens. Then there was only one point left! The 450 points were on the same place!
Saludos, Birgit
hello
i thoutht that my montecarlo worked in 3.0 so i did another montecarlo in 3.1
i do not see the problem
saludos
http://www.geogebra.org/en/...
Hy,
The problem seems to be solved in GG 3.1.100 but I've an other problem :
"sequence[if[Random[1,10]>2,0,1],i,1,100]" doesn't work. The random results in the list are the same i.e. {0,0,0 ...} or {1,1,1...}
Regards
Luc
:laughing:
if[Random[1,10]>2,0,1]
^^^
Sure ... Random produces Numbers from 1 to 10, but the IfCommand produces the 0 and 1.
Birgit,
Maybe my post was not clear because of my poor english. I've edit it, so that you understand the problem.
The random[] command is not revaluated when it is in an if[] command ( or in a boolean expression ).
Regards
Luc
hello
now you must update the random value writing
sequence[if[Random[1+0 i,10]>2,0,1],i,1,100]
next versions will do it with F9 key
also you can updated the list doing
a=1
sequence[if[Random[1+0 i a,10]>2,0,1],i,1,100]
and modifying "a"
(you can suposse if you want sequence[(i,random[0,10] i1), i,1,20] for colineal points in random line; if random updates automatically this would be unpossible)
saludos
Thanks,
It works with random[ 1 + i*0 , 10 ] !
Best Regards
Comments have been locked on this page!