Friday, December 11, 2009

Turtle random V2

Uses Turtle Art to simulate repeated trials of n (25) coin tosses, for large n and a large number of trials, the normal bell shaped distribution results.

Utiliza Turtle Art para simular la repetición de pruebas de n (25) lanzamientos de la moneda, para n grande y un gran número de ensayos, la campana en forma de resultados normales de distribución.

(Has been also done with Game Maker)


Uses the Python code block to hold coding for the n bins. Use Pippy to edit the Python code.
Load the Python code into your block with the load my block button:

def myblock(lc,x):
....n= int(lc.heap.pop(-1)) #n number of bins
....bin=[0]*n # set up array size n
....if x ==-1: #-1 initialises heap
........for i in range (n):
............lc.heap.append(0)
....else: #!=-1 so is a real trial
........for i in range (n):
............bin[i]= lc.heap.pop(-1)
............if i==x:
................bin[i]+=1
........for i in range (n):
............lc.heap.append(bin[i])
........for i in range (n):
............lc.heap.append(bin[i])
....return



Update September 2010
This version, in Spanish, uses multiple turtles for a simple solution
Esta versión, en español, utiliza las tortugas múltiples para una solución simple


*.ta source load this source and the block labels will display in the language set on Sugar.

Labels: , , ,

0 Comments:

Post a Comment

<< Home