Just to remind youwhere we are,
we have two constraints,
one is, the expectation value of x,
the average waiting time is four minutes,
the other is that the probabilities
sum to 1.
Those are our two constraints,
and then what we're going to do is
maximize the entropy of a distribution,
subject to those constraints.
Okay? So S is going to be the entropy
function,
and we're not going to have 1 g,
but in fact 2 gs, okay?
One g is this function,
one g is this function. Okay?
So, how do you do maximization,
under constraints,
for more than one constraint?
I gave you an intuitive picture
about how you could do one
constraint at a time,
but how could you do two constraints?
I'm going to tell you the answer,
because it's much harder to work through
the problem of multiple constraints,
but it's an intuitive answer, one that is
worth remembering,
and if you ever want to work through it,
there's plenty of places to find the
answer.
So, here's how to do lagrange multipliers,
the method of lagrange multipliers,
you remember the lagrange multiplier
is that lambda term, okay? And so,
that's where the method get its name from,
you want to maximize the function f,
subject to a set of constraints, now,
and we'll number these constraints
g sub i, so g1, g2, all the way through
your n constraints however
many you have,
and the way you do that is you set the
gradient of the function equal to
a linear combination of the gradients of
the constraints.
So, here's the case where you have
n constraints.
So, this is the general method of
lagrange multipliers,
in order to maximize this function subject
to these n constraints,
set the gradient of the function f equal
to some linear combination
of gradient of the function g, and
then the problem
is just how do you find g. What you know
is, you know your maximum point
is such that you can add together all of
these gradients in such a way,
with some weight so that you can reproduce
the original gradient of the contours.
Okay? And so, now the problem is, what
are these Ls, or what are these lambdas,
so what I'm going to do is, I'm going to
walk you through, now the problem of
maximum entropy, using this formula here,
and if these seem mysterious right now,
by the end, they hopefully should not be.
What you're going to do is turn knobs,
and twiddle knobs around,
until you get the lambda such that
those lambdas satisfy the particular
constraint values you have in mind.
So, we're going to maximize not arbitrary
function f, but in fact the entropy,
and our constraints are going to be a
constraint on the average, and
a constraint on the normalization. So,
we want the derivative of S
with respect to p_i, we do this term by
term in the vector,
we want that to be equal to lambda1,
times the derivative of g1 wrt p_i,
plus lambda2 times the derivative of g2,
with respect to p_i. Okay?
So this reminds you, S is the entropy
of the distribution,
S is equal to minus the sum over all possible
waiting times.
So again, just for convenience's sake,
I'm talking about the discrete case,
you can take limits, if you have your
measures set up correctly,
and you can turn this into integrals,
and turn this into integrals,
and this as well into integral.
But it's easier just conceptually, to talk
about the discrete case first.
So, g1, remember, this is a function of p,
alright, p is a vector here, okay?
g1 is just the sum i 0 to infinity, okay,
of p_i times i.
and I'm using just, I'm using i now
instead of x,
it's easier to write for me. Okay?
So, this is the constraint function, okay,
that constraints the average value.
And of course what we want in the end is
we want g1(p) to be equal to 4 minutes.
g2(p) is just the normalization constraint
so the function just looks like summing
over all values of p, and of course in the
end what we'll do is we'll take g2 = 1.
And we previously defined the entropy
here.
So, what if the derivative of the entropy,
with respect to a particular probability,
right, a particular probability of a
particular configuration, okay? So,
Alright move this out here, S is equal to
negative p_i log p_i i from 0 to infinity,
okay? So, dS/d(p_i), equals, well the only
term that's going to survive is
where you have the p_i in it, and then
we have the derivative of p_i log p_i,
that has two terms: log p_i, and then the
other one is p_i times the derivative of
log p_i. derivative of log p_i is 1/p_i,
so in fact, you have plus 1.
So, this is the left hand side of your
lagrange multiplier equation.
And just to remind you, we set the base
of the log to e.
So, now we have to take the derivative of
g1 with respect to p_i,
okay? So again, take the derivative of
this sum here with respect to p_i,
and what of course you'll find, is that
dg1/d(p_i) = i,
and finally, dg2/d(p_i) = 1.
There's only 1 term in the sum that
doesn't get destroyed by the derivative.
So, let's now put all this together,
we have negative log p_i -1 is equal to
lambda1, times the derivative of g_1,
with respect to p_i, which is i, plus the
derivative of g2 with respect to p_i,
times lambda 2, so this is now our
equation, okay, that is satisfied
when you try to maximize the entropy,
try to maximize this function,
subject to these constraints, for some
value of the constraint.
So let's solve for p_i. So, let's move
things around here,
and we have negative 1 minus lambda1 i,
minus lambda 2, equals log p_i,
we'll exponentiate both sides, flip them
around, and we have
p_i is equal to e to the negative 1 minus
lambda1 i, minus lambda 2. Okay?
And, we can write that somewhat more
succinctly in the following way,
e to the lambda1 i divided by Z,
where Z is equal to e to the 1
plus lambda 2.
The probability of waiting for a certain
time i, is equal to e to the negative
lambda1 times i, there's an exponential
distribution of waiting times.
Now, all that remains is to figure out
what on earth lambda1 is,
and what on earth Z is.
And what we're going to do is we're going
to turn, we're going to figure out
the value you have to set lambda1 to,
in order to satisfy this particular value
of the constraint,
and this particular value of the
constraint. So,
we know the functional form of the
distribution,
and now we just have to figure out the
parameters of that function.
And there will be two parameters.
So the first thing we know is of course,
that the probability is normalized, and
that means in fact that,
okay?
plugging in this functional form, and so
now, already, we can solve for Z
in terms of lambda1. So, eliminating the
first variable here, Z, is easy.
We can just set Z equal to the sum from i
0 to infinity, e to the negative lambda1 i
okay? So we already eliminated one
variable,
and now, all we have to do is to solve
for the other constraint. Okay?
In particular, just let me write this here
In particular, we have the sum from i 0 to
infinity times e to the negative lambda1 i
i, all over Z, that has to be equal to 4.
Solo para recordarle donde estamos,
tenemos dos restricciones.
Una es el valor esperado de x,
el tiempo promedio de espera es 4 minutos.
la otra es que las probabilidades suman 1.
Esas son nuestras 2 restricciones,
y lo que vamos a hacer es
maximizar la entropía de la distribución
sujeta a estas restricciones.
¿Bien? Entonces,
S va hacer la función de entropía,
y no vamos a tener una g,
sino, de hecho dos g, ¿Bien?
Una g es esta función,
una g es esta función, ¿Bien?
Así que... ¿Como se hace maximizaron
con restricciones,
para mas de una restricción?
Le di una idea intuitiva
de como hacerlo
con una restricción a la vez,
¿Pero como se hace con 2 restricciones?
Voy a decirle la respuesta,
porque es mucho mas difícil de trabajar
el problema de múltiples restricciones
Pero la respuesta es intuitiva,
y vale la pena recordarla.
Y si alguna vez quiere resolverlo
hay muchos lugares
donde conseguir la respuesta
Así que, así es como se trabaja con
multiplicadores de Lagrange,
el método de multiplicadores de Lagrange,
¿Recuerda los multiplicadores de Lagrange?
Es este termino lambda, ¿Bien? Entonces,
el método obtuvo su nombre de ahí,
si quiere maximizar la función f,
sujeta a un grupo de restricciones,
ahora,
vamos a numerar las restricciones g sub i,
así, g1, g2, y así sucesivamente
sus n restricciones,
cuantas sea que tenga,
y la forma de hacerlo es ajustar
el gradiente de la función igual a
una combinación lineal de gradientes
de las restricciones.
Entonces, este es el caso donde tiene
n restricciones.
Así que, este es el método general de los
multiplicadores de Lagrange,
Para poder maximizar esta función sujeta
a estas n restricciones,
ajuste el gradiente de la función f
igual a una combinación lineal
de gradiente de la función g, y
entonces el problema
se reduce a encontrar g. Lo que usted sabe
es... Sabe que su punto máximo
es tal que puede sumar todos
los gradientes de forma tal que,
con algunos coeficientes tales que pueden
reproducir el gradiente del los contornos.
Entonces, ahora el problema es ¿cuales son
estos Ls, o cuales son son estos lambdas?
Así que los que voy a hacer es guiarlo,
ahora el problema de máxima entropía,
usando esta formula,
y si esto parece misterioso ahora,
para el final, ojala no lo sera.
Lo que va a hacer es girar perillas,
y juguetear con las perillas,
hasta que obtenga un lambda tal que
esos lambdas satisfagan los valores de la
restricción particular que tiene en mente.
Entonces, no vamos a maximizar una función
f arbitraria, sino de hecho la entropía,
y nuestras restricciones van a ser
la restricción de el promedio,
y la restricción de la normalización.
Entonces, lo que queremos derivar S
con respecto a p_i, lo hacemos
termino por termino en el vector,
queremos que eso sea igual a lambda 1,
por la derivada de g1 con respecto a p_i,
mas lambda2 por la derivada de g2
con respecto a p_i ¿Bien?
Esto es para recordarle que
S es la entropía de la distribución,
S es igual a la suma negativa sobre
todos los posibles tiempos de espera.
Así que de nuevo, por conveniencia,
estoy hablando del caso discreto,
puede hacer limites, si tiene sus medidas
configuradas correctamente,
y puede transformar estas en integrales,
y transformar estas en integrales,
y esto también lo transforma
en integrales.
Pero es mas fácil conceptualmente
hablar primero del caso discreto.
Así , g1, recuerde, esto es una función
de p, bien, p aquí es un vector ¿Ok?
g1 es solo la suma de i_0 a infinito de
p_i veces i.
y estoy usando solo, estoy usando ahora i
en vez de x,
es mas fácil de escribir para mi, ¿Ok?
Así, esta es la función de restricción,
que restringe el valor promedio.
Y claro, lo que queremos al final es que
queremos que g1(p) sea igual a 4 minutos.
g2(p) es la restricción de normalización,
así la función parece la suma
sobre todos los valores de p, y claro,
al final lo que haremos es hacer g2 = 1.
Y previamente definimos la entropía aquí.
Entonces
¿Cual es la derivada de la entropía con
respecto a probabilidad particular ¿Bien?
Una probabilidad en particular de una
configuración en particular?
Muy bien, esto aquí es, S es igual a menos
p_i log p_i con i desde 0 hasta infinito.
¿Bien? Así que, dS(p_i), es igual a... el
único termino que va a sobrevivir que es
el que tiene la p_i, y luego tenemos la
derivada de p_i log p_i,
que tiene 2 términos: log p_i, y el otro
que es p_i por la derivada de log p_i.
La derivada de p_i, así que
de hecho tiene un mas uno (+1),
entonces este es el lado izquierdo de su
ecuación de multiplicadores de Lagrange.
y solo para recordarle que usamos
logaritmo base e.
Así que, ahora tenemos que hacer la
derivada de g1 con respecto de p_i,
¿Ok? Otra vez, hacemos la derivada de esta
suma de aquí con respecto a p_i,
y obviamente lo que vamos a encontrar
es que dg1/d(p_i) = i,
y finalmente, dg2/d(p_i) = 1.
Solo hay un termino en la suma
que no se destruye con la derivada.
Entonces, juntemos todo esto,
tenemos menos log p_i - 1 que es igual a
lambda 1 por la derivada de
g1 con respecto a p_i, lo que es i, mas
la derivada de g2 con respecto a p_i,
por lambda 2, así que esta es nuestra
ecuación ¿Ok? Que se satisface
cuando trata de maximizar la entropía,
intente maximizar esta función,
sujeta a estas restricciones,
para algún valor de las restricciones
Entonces vamos a resolverla para p_i.
Así que vamos a mover las cosas por aquí,
y tenemos menos 1 menos lambda 1 i,
menos lambda 2, igual a log p_i,
vamos a elevar ambos lados,
voltearlos, y tenemos
p_i es igual a e a la menos 1,
menos lambda 1 i, menos lambda 2 ¿Ok?
Y podemos escribirlo de manera
mas breve de la siguiente manera,
e a la lambda 1 i dividido por Z,
donde Z es igual a e a la 1 mas lambda 2.
La probabilidad de esperar algún tiempo i,
es igual a e a la menos lambda 1 veces i,
hay una distribución exponencial de
tiempos de espera.
Ahora, todo lo que queda es determinar
que rayos es lambda 1,
y que rayos es Z.
Y lo que vamos a hacer es ajustar,
vamos a determinar
el valor al que se tiene que ajustar
lambda1
para poder satisfacer el valor
particular de la restricción
y este valor particular de la restricción,
Entonces, conocemos
la forma funcional de la distribución,
y ahora solo tenemos que determinar
los parámetros de la función.
Y habrá dos parámetros.
Así que lo primero que
sabemos es, por supuesto,
que la probabilidad esta normalizada,
y esos significa que efectivamente
¿Ok?
Insertando esta forma funcional, y así,
ahora, ya, podemos solucionar Z
en términos de lambda1. Así que, eliminar
la primera variable de aquí Z, es fácil.
Podemos hacer Z igual a la suma de i a
infinito, e a al valor negativo lambda 1 i
¿Ok? Entonces, ya hemos
eliminado una variable,
y ahora, todo lo que tenemos que hacer es
resolver para las otras restricciones,
¿Ok? En particular,
Solo déjeme escribir esto aquí.
En particular, tenemos la suma de i de 0 a
infinito por e a la menos lambda1 i
i, todo sobre Z, tiene que ser igual a 4.
Ricordiamoci di avere due condizioni
una, il valore atteso di x, media di attesa
di 4 minuti
l'altro è la probabilità che la somma
sia 1
Queste le nostre condizioni,
e ora rendiamo
massima l'entropia di una distribuzione,
soggetta a queste condizioni.
Ok? S sarà la nostra funzione di entropia
e non avremo 1 g ma 2 g, ok?
Una g questa funzione,
l'altra g questa. Ok?
Come la rendiamo massima
sotto queste condizioni
per più di una condizione?
Intuitivamente,
come possiamo raggiungere non
una condizione
ma due?
Vi darò la risposta,
essendo assai più complicata operare
con condizioni multiple
ma è una risposta intutitiva, sempre
la peggiore da ricordare
e se volete lavorarci
ci sono una serie di posti dove trovare
la risposta.
Qui come risolvere i moltiplicatori di Lagrange
il metodo dei moltiplicatori di Lagrange,
ricordate il moltiplicatore di Lagrange
è il termine lambda, okay? E quindi,
da questo deriva anche l'origine del suo nome
vogliamo massimizzare la funzione f
soggetta ad una serie di condizioni, ora,
e chiameremo queste condizioni,
g sub i, g1, g2, fino a
n condizioni
e il modo di operare è impostare
il gradiente della funzione uguale ad
una combinazione lineare dei gradienti
delle condizioni.
Questo quando hai n condizioni.
Questo è, in generale, il metodo dei
moltiplicatori di Lagrange,
per massimizzare la funzione soggetta
a n condizioni,
impostare il gradiente della funzione f uguale
ad una combinazione lineare
del gradiente della funzione g, e
il problema
è come trovare g. Quello che sappiamo
è, il punto di massimo
è tale che si possono aggiungere insieme tutti
questi gradienti,
con un misura per riprodurre il gradiente
originale dei contorni.
Ok? E, ora il problema è, cosa
sono queste L, o quali sono queste lambda,
proveremo a risolverlo insieme,
il problema della massima
entropia, usando questa formula,
anche se ora sembra una cosa oscura,
alla fine, non la sarà affatto.
Girate le manopole
finché non ottenete la lambda in modo che
queste lamnda soddisfino una particolare
condizione di un valore che avete in mente.
Proviamo a massimizzare non un'arbitraria
funzione f, ma l'entropia,
e le nostre condizione saranno la condizione
della media, e
una condizione sulla normalizzazione. La derivata
di S
rispetto a p_i, passo dopo passo nel vettore,
vogliamo che sia uguale alla labda1,
per la derivata di g1rispetto a p_1,
più lambda 2 per la derivata di g2
rispetta a p_i. Ok?
Ricordate, S è l'entropia
della distribuzione,
S è uguale a meno la somma di
tutti i possibili tempi di attesa.
Di nuovo, per convenienza,
parlerlò di un caso discreto,
potete prendere i limiti, se potete
impostare misure esatte,
e poi farli diventare integrali,
e da questo degli integrali
e così quest'altro.
Ma è più facile concettualmente, parlare
dapprima di un caso discreto.
Quinid, g1, ricordate, la funzione di p,
è un vettore qui, ok?
g1 è la somma i da 0 a infinito, ok,
di p_i volte i.
E uso i invece di x
perchè più facile da scrivere. Ok?
Questa è la funzione della condizione, ok,
che lega il valore medio.
E vogliamo alla fine g1(p) uguale
a 4 minuti.
g2(p) è la condizione di normalizzazione
in modo che la funzioni sia la somma
di tutti i valori di p, e alla fine
prenderemo g2 = 1.
E precedentemente abbiamo definito qui
l'entropia.
Quindi, cosa accadrebbe se la derivata dell'entropia,
rispetto ad una particolare probabilità,
giusto, una particolare probabilità di una
particolare configurazione, ok?
Spostiamolo qui, S è uguale al negativo
p_i log p_i da 0 a infinito,
ok? dS/d(p_i), uguali, l'unico termine
che rimarrà è
dova avete p_i in questo, e poi
abbiamo la derivata di p_i log p_i,
questi hanno due termini: log p_i,
e poi l'altro p_i per la derivata di
log p_i, la derivata di log p_i è 1/p_i,
infatti avete +1.
Sulla sinistra dell'equazione del vostro
moltiplicatore di Lagrange.
Ricordate, abbiamo impostato la base
del log ad e.
Ora prendiamo la derivata di
g1 rispetto a p_i,
ok? Di nuovo, prendiamo la derivata di
questa somma rispetto a p_i,
e troverete,
dg1/d(p_i) = i,
e infine, dg2/d(p_i) = 1.
C'è solo un termine della somma che non
sarà distrutto dalla derivata.
Mettiamoli insieme,
abbiamo meno log p_i - 1 uguale a
lambda1, per la derivata di g_1,
rispetto a p_i, che è i, più la
derivata di g2 rispetto a p_i,
per lambda2, ecco la nostra equazione, ok,
che soddisfa
il tentativo di massimizzare l'entropia,
proviamo a massimizzare questa funzione,
soggetta a queste condizione, per alcuni
valori della condizione.
Risolviamo per p_i. Spostiamo un po'
di cose
e abbiamo meno 1 meno lambda1 i,
meno lambda 2, uguale a log p_i,
eleviamo entrambi i lati a potenza,
capovolgiamoli, e abbiamo
p_i uguale a -1 meno lambda1 i,
meno lambda 2. Ok?
E, in maniera più succinta
possiamo scrivere così
e alla lambda1 i diviso per Z,
dove Z è uguale a e a 1 più lambda2.
La probabilità di attesa di un certo
tempo i è uguale a e a meno
lambda1 per i, distribuzione
esponenziale dei tempi di attesa.
Ora, non resta che descrivere
cosa rappresenta lambda1,
e Z.
Trasformiamo, descriviamo, cioè,
il valore
impostato a lambda1
per soddisfare un particolare valore della
condizione,
e questo particolare valore della
condizione. Così,
la forma della funzione della
distribuzione,
e ora descriviamo i parametri
di quella funzione.
Ci saranno due parametri.
La prima cosa che sappiamo è
che la probabilità è normalizzata,
ovvero,
ok?
inseriamo nella funzione, e ora
possiamo risolvere per Z
in termini di lambda1. Eliminiamo la
prima variabile Z, è facile.
Possiamo impostare Z uguale alla somma i da 0
a infinito, e da meno lambda1 i
ok? Abbiamo già eliminato
una variabile.
e ora, dobbiamo risolvere
per questa condizione. Ok?
In particoalre, scriviamo qui
In particolare, abbiamo la somma da i con 0 a
infinito per e a meno lambda1 i
i, su Z, uguale a 4.