Skip to content

Instantly share code, notes, and snippets.

@arivero
Created August 28, 2012 15:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arivero/3499187 to your computer and use it in GitHub Desktop.
Save arivero/3499187 to your computer and use it in GitHub Desktop.
estadistica de una distribucion de nodos
if True:
informa=0
print cantidad[:50]
print numero[:50]
ricos=sum(cantidad[:len(cantidad)/100])
print "hemos repartido ", total , " entre ", sum(numero),
print " (media=",1.0*total/sum(numero), ")", reparto
print "el mas rico posee ", 1.0*cantidad[0]*sum(numero)/total, "veces mas que la media"
ricosnum,ricoscant,xx=0,0,-1
for corte in 10000,1000,100,20,10,5,10.0/3,10.0/4,2,10.0/6,10.0/7,10.0/8,10.0/9,10.0/9.5,10.0/9.9:
while ricosnum<sum(numero)/corte:
xx+=1
ricosnum+=numero[xx]
ricoscant+=cantidad[xx]*numero[xx]
resto=ricosnum-sum(numero)/corte
exacto=ricoscant-resto*cantidad[xx]
#print "el ", 100.0*ricosnum/sum(numero), "% posee el ", 100.0*ricoscant/total ,"%"
print "el", 100.0/corte, "% posee el ", "%02.2f"% (100.0*exacto/total) ,"%"
print "tenemos un array de ", len(numero), " elementos con ",
print sum(x==0 for x in numero), " ceros"
bins=[0,]*int(1+log(cantidad[0],2))
while xx >= 0:
bins[int(log(cantidad[xx],2))]+=numero[xx]
xx-=1
print bins
print ["%4.4f"%log(x+0.00000000001,2) for x in bins]
print ["%4.4f"%(log(bins[xt]+0.00000000001,2)-log(bins[xt+1]+0.00000000001,2)) for xt in range(len(bins)-1)]
print "===================================================================="
@arivero
Copy link
Author

arivero commented Aug 31, 2012

Ojo que la info que sacamos de los bins implica ya una integracion, y por ello la diferencia de logs extrae el exponente de la distribucion acumulada y no de la pdf

@arivero
Copy link
Author

arivero commented Jan 20, 2014

Este gist es el de sumar los resultados. Para generar puedes usar por ejemplo este

https://gist.github.com/arivero/8529263

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment