ho cercato di applicare le idee di quel parlare, in modo un po 'semplicistico.
Il mio sistema immaginario aveva una variabile, con rumore uniforme aggiunto e feedback positivo. Pensa all'angolazione di un bastone che viene bilanciato su un bastone nel campo gravitazionale. L'evoluzione del mio sistema immaginario in un tick di tempo è stato descritto come
def simulate1(theta):
# introduce evil random displacement
theta = theta + random.uniform(-noise, noise)
# apply stipid physics laws
f = math.sin(theta)
theta = theta + f*dt
return theta
#
# simulate evolution of the system during so many ticks
#
def simulate(theta, ticks):
thetas = []
for _ in range(ticks):
theta = simulate1(theta)
thetas.append(theta)
return thetas
Se corro questa simulazione, theta va rapidamente a PI o -PI e oscilla lì.
Ora io introdurre la nozione di calci (qui ci sia non fare nulla o calciare il sistema a sinistra oa destra, 5 volte più duro che il rumore fa):
kicks = [0, -5*noise, 5*noise]
Infine, arriviamo al ciclo principale. Su ogni iterazione il seguente aggeggio considera la possibilità di dare al sistema di un calcio e calcolato una metrica (si spera) correlato alla varietà dei futuri (non entropia come nella domanda iniziale):
while True:
best_kick = None
for kick in kicks:
median_var = simulate_median_var(theta + kick)
if (best_kick is None) or (median_var > best_median_var):
best_median_var = median_var
best_kick = kick
print "theta=%f\tbest_kick=*\t\tbest_median_var=%f" % (theta, best_median_var)
theta = theta + best_kick
theta = simulate1(theta)
E qui è effettiva attuazione di metrica:
#
# estimate variation of possible future
# assume the variation is higher is standard deviation is higher (is it good one?)
#
def simulate_var(theta, ticks):
thetas = simulate(theta, ticks)
(theta_hist, _) = numpy.histogram(thetas)
#print "# %s" % theta_hist
return numpy.std(theta_hist)
# calculate median of the variaion for so many rounds
def simulate_median_var(theta):
vars = []
for _ in range(rounds):
var = simulate_var(theta, ticks)
vars.append(var)
return numpy.median(vars)
Prima di calcolare la distribuzione di probabilità di possibili stati di sistema. Quindi usiamo numpy.hist() per ordinare l'evoluzione della storia intera di theta in 10 bin. Quindi calcoliamo una deviazione standard su tutti i bin. Non è necessariamente la migliore metrica, ma sembra funzionare come stima di un ballpark.
Ecco come uscita (con un po 'di informazioni di debug extra) assomiglia:
theta=0.000000 best_kick=0.000000 best_median_var=16.443844 # [(-0.005, 12.13260071048248), (0, 16.443843832875572), (0.005, 12.13260071048248)]
theta=0.000328 best_kick=0.000000 best_median_var=16.437761 # [(-0.005, 12.320714265009151), (0, 16.437761404765553), (0.005, 12.091319200153471)]
theta=0.001096 best_kick=0.000000 best_median_var=15.811388 # [(-0.005, 12.735776379946374), (0, 15.811388300841896), (0.005, 11.798304963002099)]
theta=0.001218 best_kick=0.000000 best_median_var=15.792403 # [(-0.005, 12.743625857659193), (0, 15.792403236999744), (0.005, 11.798304963002099)]
theta=0.000433 best_kick=0.000000 best_median_var=16.437761 # [(-0.005, 12.320714265009151), (0, 16.437761404765553), (0.005, 11.958260743101398)]
theta=0.000931 best_kick=0.000000 best_median_var=16.112107 # [(-0.005, 12.625371281669304), (0, 16.112107248898266), (0.005, 11.798304963002099)]
theta=0.001551 best_kick=0.000000 best_median_var=14.913082 # [(-0.005, 13.046072205840346), (0, 14.913081505845799), (0.005, 11.661903789690601)]
theta=0.001249 best_kick=0.000000 best_median_var=15.491933 # [(-0.005, 12.759310326189265), (0, 15.491933384829668), (0.005, 11.798304963002099)]
theta=0.002275 best_kick=0.000000 best_median_var=14.021412 # [(-0.005, 13.512956745287095), (0, 14.021412197064887), (0.005, 11.523888232710346)]
theta=0.002349 best_kick=0.000000 best_median_var=14.035669 # [(-0.005, 13.527749258468683), (0, 14.035668847618199), (0.005, 11.523888232710346)]
theta=0.002224 best_kick=0.000000 best_median_var=14.085453 # [(-0.005, 13.535139452550904), (0, 14.085453489327207), (0.005, 11.523888232710346)]
theta=0.002126 best_kick=0.000000 best_median_var=14.300346 # [(-0.005, 13.512956745287095), (0, 14.300345799157828), (0.005, 11.523888232710346)]
theta=0.003034 best_kick=-0.005000 best_median_var=14.615061 # [(-0.005, 14.615060725156088), (0, 13.274034804836093), (0.005, 11.41052146047673)]
theta=-0.003091 best_kick=0.005000 best_median_var=14.587666 # [(-0.005, 11.41052146047673), (0, 13.274034804836093), (0.005, 14.587666023048376)]
theta=0.001966 best_kick=0.000000 best_median_var=14.345731 # [(-0.005, 13.274034804836093), (0, 14.345731072343439), (0.005, 11.636150566231086)]
theta=0.002721 best_kick=-0.005000 best_median_var=14.021412 # [(-0.005, 14.021412197064887), (0, 13.512956745287095), (0.005, 11.523888232710346)]
theta=-0.002635 best_kick=0.005000 best_median_var=14.021412 # [(-0.005, 11.523888232710346), (0, 13.535139452550904), (0.005, 14.021412197064887)]
theta=0.002066 best_kick=0.000000 best_median_var=14.310835 # [(-0.005, 13.29661611087573), (0, 14.310835055998654), (0.005, 11.636150566231086)]
theta=0.001485 best_kick=0.000000 best_median_var=15.198684 # [(-0.005, 12.969194269498781), (0, 15.198684153570664), (0.005, 11.781341180018513)]
theta=0.001414 best_kick=0.000000 best_median_var=15.201973 # [(-0.005, 12.984606270503546), (0, 15.201973200284616), (0.005, 11.781341180018513)]
theta=0.000542 best_kick=0.000000 best_median_var=16.431676 # [(-0.005, 12.328828005937952), (0, 16.431675598153642), (0.005, 11.958260743101398)]
theta=0.000726 best_kick=0.000000 best_median_var=16.443844 # [(-0.005, 12.521980673998822), (0, 16.443843832875572), (0.005, 11.958260743101398)]
theta=0.000633 best_kick=0.000000 best_median_var=16.437761 # [(-0.005, 12.433824833895642), (0, 16.437761404765553), (0.005, 11.958260743101398)]
theta=-0.000171 best_kick=0.000000 best_median_var=16.437761 # [(-0.005, 12.116104984688768), (0, 16.437761404765553), (0.005, 12.255610959882823)]
theta=-0.000934 best_kick=0.000000 best_median_var=15.824032 # [(-0.005, 11.798304963002099), (0, 15.824032355881986), (0.005, 12.545915670049755)]
theta=-0.000398 best_kick=0.000000 best_median_var=16.440803 # [(-0.005, 11.958260743101398), (0, 16.440802618820562), (0.005, 12.320714265009151)]
theta=-0.001464 best_kick=0.000000 best_median_var=14.913082 # [(-0.005, 11.661903789690601), (0, 14.913081505845799), (0.005, 12.969194269498781)]
theta=-0.002141 best_kick=0.000000 best_median_var=14.310835 # [(-0.005, 11.532562594670797), (0, 14.310835055998654), (0.005, 13.512956745287095)]
theta=-0.002893 best_kick=0.005000 best_median_var=14.314328 # [(-0.005, 11.41052146047673), (0, 13.512956745287095), (0.005, 14.314328059637504)]
theta=0.003015 best_kick=-0.005000 best_median_var=14.314328 # [(-0.005, 14.314328059637504), (0, 13.274034804836093), (0.005, 11.41052146047673)]
theta=-0.002201 best_kick=0.000000 best_median_var=14.042792 # [(-0.005, 11.532562594670797), (0, 14.042791745233567), (0.005, 13.45362404707371)]
theta=-0.002234 best_kick=0.000000 best_median_var=14.042792 # [(-0.005, 11.523888232710346), (0, 14.042791745233567), (0.005, 13.512956745287095)]
theta=-0.001903 best_kick=0.000000 best_median_var=14.473666 # [(-0.005, 11.653325705565772), (0, 14.473665878659745), (0.005, 13.274034804836093)]
theta=-0.002782 best_kick=0.005000 best_median_var=14.085453 # [(-0.005, 11.41052146047673), (0, 13.520355024924458), (0.005, 14.085453489327207)]
theta=0.003083 best_kick=-0.005000 best_median_var=14.587666 # [(-0.005, 14.587666023048376), (0, 13.274034804836093), (0.005, 11.41052146047673)]
theta=-0.001439 best_kick=0.000000 best_median_var=15.491933 # [(-0.005, 11.661903789690601), (0, 15.491933384829668), (0.005, 12.961481396815721)]
La simulazione di cui sopra è stata fatta con:
noise = 0.001 # noise amplitude
kicks = [-5*noise, 0, 5*noise] # what kicks to try
ticks = 100 # now many time ticks to simulate
rounds = 1000 # now many rounds to simulate
dt = 0.1 # simulation rate koefficient, something like dt
mi rendo conto che non segue esattamente la matematica in originale carta, ma (piuttosto impropriamente) usa la sua idea generale.
Vale la pena notare che questi tipi di domande non sono on-topic per Stack Overflow. Non ho intenzione di dare un voto ravvicinato perché penso che la domanda sia migliore di molte altre domande apparentemente valide che il tag Python ottiene, ma immagino che ne faranno altre. Fondamentalmente, la frase "grato per i suggerimenti sulle librerie" non è appropriata per questo sito, sebbene tu possa provare la chat o altre risorse (come la mailing list di Python). – Veedrac
+1 per il pensiero e la chiarezza messi in questa domanda. Inoltre, non ho il livello di comprensione richiesto in questo momento per tentare di rispondere :) –
@Veedrac, ho modificato il fraseggio. Sebbene questa sia una richiesta per un elenco di cose, tutte le voci dell'elenco riguardano l'I/O di un algoritmo.Ho studiato Meccanica quantistica ed Entropia per circa due giorni, ma l'argomento è profondo, e sono più interessato agli aspetti I/O dell'algoritmo. –