Sunday, June 16, 2013

Studying the Thesis of PhD Heroes: Munmun De Choudhury

Given that I am in the process of beginning to write my PhD thesis, I am currently reviewing the PhD thesis of doctors that have been more than successful in their career; these are people I admire and find inspirational for my own PhD path: my PhD heroes.
I have decided to create blog posts that describe some of the main contributions that these PhD thesis had, the new ways of thinking that these doctors brought in. I will begin this series with the PhD dissertation of Munmun De Choudhury, currently working in Microsoft research; she has several publications in top conferences such as CSCW, CHI, ICWSM, WWW, among others. Munmun is indeed one of my main true PhD heroes.

 Her thesis focused on designing frameworks and computational models to obtain a detailed understanding of how communication happens in online social networks. It was considered that online communication patterns are divided  in two main forms: the actual message discussed, and the channel or media used to discuss the message.  Work before Dr. De Choudhury's thesis focused  more on studying the network structure and dynamics, and little emphasis was given to providing tools that could characterize the type of messages present in an online community, providing insightful  observational studies on large-scale social communication datasets.

In particular, her research explored 3 main areas: (1) how information is diffused in an online social network, analyzing in particular how the influence of users and the fact that you can have very many similar users talking to each other, affects information spread; (2) how communication dynamics in online communities can be modeled, particularly focused on external and internal communication factors; (3) how "interestingness" of conversations can be modeled and measured , in particular focusing on detecting interesting conversations and identifying the features that turn them into interesting content.

Providing means to explore and analyze what are the dynamics and impact of our online social communications is important because social media data has shown to originate and create real world revolutions, think e.g., elections in Iran, Earthquake in Haiti. Social media also enables viral marketing, enabling collaborations in corporations, and can help users find experts, or even people that can help them connect with others.

In the following we begin exploring in detail each of the main themes discussed in her thesis.

Measuring the Intrestingness of a Conversation: The work considered that a conversation was interesting, when it made participants return to the conversation and continue commenting and posting. Such behavior is observed frequently on youtube, when users have already watched the video, yet they are returning to the video to comment and respond to others.
The work considered that people will participate and return to conversation when the theme of the conversation is engaging and/or interesting people are participating in the discussion. They predicted that users will return to a conversation, when they:  (a)  find the whole conversation theme interesting;  (b) see comments by people that are well known in the community; (c) observe an engaging dialogue between two or more people (an absorbing back and forth between two people).
Additionally conversations that are interesting will be propagated throughout the network; we will observe things like: users will seek other users who participated in interesting conversations; interesting themes will tend to be present in other conversations in the community; users who participated in the interesting conversations will search for other similar conversations about the same theme.
Themes are defined as a sets of salient topics associated with conversations at different points in time.

Interesting users are defined as users who after they comment, they receive a wide variety of comments from others; users that tend to participate in conversations that are currently popular in the community; users that tend to comment and engage in conversations with other interesting users.

Theme modeling: Within the modeling of themes, an idea that I found interesting from this thesis is that while there was a focus on modeling what themes were present in a conversation in a given time period, there was also an emphasis on normalizing the amount of content that was associated with a theme based on time and based on co-participation. This helped identified themes that were not only temporally popular or interesting due to an external event, or themes that certain users tended to frequently comment, not so much because the conversations around the theme were interesting, but rather because they had a probable passion for the subject.

Information Difusion:
(post in progress...come back soon!:)

Wednesday, November 14, 2012

Another layman's explanation of: Expert Evolution in Online Social Networks

I was recently reading a very interesting paper titled: Evolution of Experts in Question Answering Communities by Aditya Pal, Shuo Chang and Joseph Konstan. And thought I would share the paper and intend to explain it in Layman's terms.
There has been vast amount of work done in detecting experts in Question Answering Communities, typically this analysis is either through graph based methods or feature based methods. Graph based methods tend to analyze the link structure of a user in an online social network to find authoritative users. They analyze things such as: to how many other people is the user "friends" to? Feature based methods, on the other hand, analyze the characteristics of the users: how many best answers does the user have? What language style does he use? etc etc
The work we are analyzing seeks to identify experts, but then does a temporal analysis, to study how experts evolve in a community and how they influence a community's dynamics. The online community studied is Stackoverflow. To identify experts, the authors used two approaches: On one hand, they identify the number of positive votes a user's answerers and questions have received (a user gets a positive vote, when his/her answer is helpful to the community, or when his/her question is interesting or relevant to someone in the community) and labeled the top 10% of users with the highest number of votes as experts.
To analyze how experts evolve and how a community can be influenced in time by the answers and social interactions of experts, the authors performed the following:
  1. the questions and answers of the community were divided into bi-weekly buckets. Were the first bucket would hold the questions and anwsers of the first two weeks of the stackoverflow data they had collected, the second bucket the questions and answers created in the 3-4th weeks etc etc 
  2. For each user it is then possible to calculate per bucket (per every 2 weeks,) the number of questions, answers and best answers he/she have given. 
  3. For each user a relative time series is computed of each data type he/she has generated (questions, answers and best answers). This relative time series is constructed so that the contribution of a user can be valued relatively to the contribution of other users. For this, what is done,  is that in each of the time buckets the mean and standard deviation for each data type  are calculated. (lets recall that a bucket holds the number of answers, questions and best answers different  users have given in that particular time period, so for each type of variables, we can calculate the mean and standard deviation. It is then possible to normalize a data point in the time bucket as:
    X_b=(X_b - Mean_b)/(standardDeviation_b)

    Where X_b represents the number of answers a particular user has generated in time bucket b. And Mean_b represents the mean of all the number of answers different users have given in time bucket b
  4. After this step, each user is associated with 3 relative time series: the time series of their answers, questions and best answers. From the answers and best answer time series, a point wise ratio between best answers and answers is then calculated. This point wise ratio indicates  the probability of a user's answers being selected as the best answer.
    The following figure shows an interesting plot where we see how the likelihood of an expert and an average user receiving the votes for best answer changes over time.

What we notice is that the likelihood of receiving the best answer increases significantly over time for experts in comparison to average users. Initially the likelihood of receiving a best answer is the same for both experts and average users. The authors believe that this occurs, because when a new person, who happens to be an expert, joins the community, other users are wary of marking the answers of newcomers as the best. But as the expert gains reputation, the rest of the community members become more and more comfortable in marking their answers as the best.
The next interesting thing the author's analyzed was the the likelihood of having a user ask a question. It was seen that in general expert users do not ask questions. They found that the overall question to answer ratio among experts was 1/15 !!! To compare the time series of questions and answers, the authors computed an aggregate time series of the number of questions and answers of experts, and then normalize the time series such that it has mean=0 and standard deviation =1. From these two resulting distributions (questions and answers) a cross-covariance was computed. Now, the cross-covariance will give us information about just how similar two signals are, as a function of a time-lag applied to them. The authors found that the optimal time lag was zero for the majority of expert users. Which indicates that likelihood of an expert asking or responding to a question vary simultaneously.

Friday, July 27, 2012

Layman's Explanation of Online LDA

Topic Modeling!
LDA stands for Latent Dirichlet Allocation, and it is a type of topic modeling algorithm. The purpose of LDA is to learn the representation of a fixed number of topics, and given this number of topics learn the topic distribution that each document in a collection of documents has. For example, if we were given the following sentences:
A:I spend the day at the beach tanning.
B: I ate Mexican Tacos and Guacamole.
C:I love tanning in Mexican beaches while eating quesadillas and tacos under the sun.


LDA might say something like:
Sentence A is 100% about Topic 1
Sentence B is 100% Topic 2
Sentence C is 30% Topic 1, 70% Topic 2


where LDA also discovers that:
Topic 1: 30% beach, 15% tanning, 10% sun, … (where we notice that topic 1 represents things related to the beach)
Topic 2: 40% Mexican, 10% Tacos, 10% Guacamole, 10% Quesadilla , … (where we notice that topic 2 represents things related to Mexico.)


LDA learns how topics and documents are represented in the following form:

1)First the number of topics to discover is selected. (Similar to when we specify the number of clusters we wish our clustering algorithm to consider)

2) Once the number of topics is selected, LDA will go through each of the words in each of the documents, and it will randomly assign the word to one of the K topics. After this step we will have topic representations (how the words are distributed in each topic) and documents represented in terms of topics (Just like the above example, where we said Sentence or Document C is 30% about Topic 1 and 70% about Topic 2.) Now, the thing is, the assignment of words to topics, was done in a random form, so of course this obtained representation is not very optimal or accurate. To better this representation LDA will analyze per document:
what is the percentage of words within the document that were assigned to a particular topic. And for each word in the document, LDA will analyze over all the documents, what is the percentage of times that particular word has been assigned to a particular topic. LDA will therefore be calculating:

1) p(topic t | document d) = percentage of words in a document d that are currently assigned to topic t.
2) p(word w | topic t) = percentage of times the word w was assigned to topic t over all documents.

LDA will decide to move a word w from topic A to topic B when:
p(topic A | document d) * p(word w | topic A)< p(topic B | document d) * p(word w |topic B)
After a while, LDA "converges" to a more optimal state, where topic representations and documents represented in terms of these topics are ok.

Now that we have understood the underlining principle about how LDA works. We will now discuss online LDA.
The problem with LDA is that the posterior probability we need to calculate in order to reassign words to topics is very difficult to compute. Therefore researchers use approximation techniques to find what this posterior probability is.
Generally algorithms for approximating this posterior probability are either based on sampling approaches or optimization approaches. Sampling approaches are typically based on Markov Chain Monte Carlo (MCMC) sampling. MCMC intends to find the posterior probability distribution by randomly drawing values from a complex distribution of interest. MCMC are named that way, because the previous sampled values (previous states) affect the generation of the next random sample value ( in other words, the transition probabilities between sample values is a function of the most recent sample value.)
Optimization approaches on the other hand, are typically based on variational inference. Variational Inference can be seen as deterministic alternative to MCMC. Variational Inference replaces MCMC's random, somewhat independent sampling, with optimization. Variational Inference seeks to optimize a simplified parametric distribution to be close in Kullback-Leibler divergence to the posterior. The following picture, intends to show how variational inference defines a subfamily of distributions, and the goal is to find a point in the subfamily distribution that is the closest to P(z|x). Similarity is measured using Kullback–Leibler divergence, which is a non-symmetric measure of the difference between two probability distributions P and Q.
Variational Inference has shown to be as accurate as MCMC, but FASTER, so this has made Variational Inference very popular when applying it to large datasets.

Now, despite the benefits Variational Inference brings. Large scale data analysis can still be difficult. What many groups have done is to use batch variational inference, where there is a constant iteration between analyzing each observation and updating dataset-wide variational parameters, but in really big datasets each iteration can become very costly and impractical...and this is where Online LDA comes to the rescue!
Online LDA is based on online stochastic optimization, which has shown to produce good parameter estimates dramatically faster than batch algorithms on large datasets.
Online stochastic optimization in LDA is about finding a balance between exploiting the knowledge gained on a particular topic assignation, and exploring new topic assignations. Note: Images from standford university and princeton university

Sunday, April 01, 2012

Social Signals and Machine interpretation

some_text

Have you found yourself alone in the dark, working on your computer feeling a tad depressed and wishing your computer could respond in some way to your mental and emotional state? You know, maybe your computer could send you some funny comics to lighten your day, or perhaps send you an inspiring quote to keep you in the fight for life....These ideas might sound a bit far fetched given our current reality with our machines. But there is actually an active community, whose goal is precisely for machines to understand human emotion and social interaction.
Having machines understand emotion and social interactions, is beneficial for:

  • Social Scientists, Psychologists and Doctors: As they all are very interested in observing and quantifying human behaviour. For Psychologists and Doctors this could help them in diagnosing and rehabilitating their patients.
  • Intelligent Algorithms: that by understanding their user better, could respond to semantic queries and retrieve more relevant material. As humans we are very familiar with interacting with different meanings given different contexts, think for example of that popular 60's song titled: "it's the same old song, but with a different meaning since you've been gone
  • Ambient intelligence: Environments can become more responsive to the social context. Perhaps the room detects that the crowd at a small reunion is bored, and so the room could maybe start playing whimsical animal figures on the walls to entertain the audience.

Overall having machines being able to interpret human emotion can improve Human Computer Interaction, as it increases the computer's sensitivity to the user's mental and emotional state [5].

Now, given that we understand the benefits of machines that can understand our emotions betters. The question is, so... how can this be enabled?

Recent investigations focus on something called SOCIAL SIGNALS.

But what is exactly a social signal?
-A social signal (According to Poggi and D'Errico) is a communicative or informative signal that conveys information about social actions, social interactions, social emotions and attitudes.

Where the heck does this idea of "Social Signal" come from?
The term "Social Signal" was inspired by various psychology studies, that analysed how non-verbal behaviour relates to social interactions. Psychologists were studying things such as:

  • How does non-verbal behaviour effect the formation of impressions? For example, apparently when you smile a lot and have rapid movements, people take this as if you are an extrovert.
  • How does non-verbal behaviour reinforce the nature of a relationship? Apparently men tend to lean forward more and gaze toward the person they are talking with, when the other person so happens to be a female, this behaviour is experienced even more if they are having an intimate conversation, rather than the general boring interpersonal water cooler chit chat.
  • Can facial movements be mapped into emotional signals and conversation signals? This is an area greatly studied in deception detection, as there are certain muscles that are expected to be moved when someone is angry, happy, sad etc. Therefore a person might unwillingly move those muscles, and show their true feelings. Or not move them, and therefore give clues as to the fact that they are being deceitful ( See [4]).

Now the big question is: O.K., So how do social signals help machines understand human emotion?
In 2007, a professor and researcher from MIT's Media Lab,Alex Pentland, introduced the notion of “social signal processing”. Which is about applying traditional signal processing techniques to social signals, and use this processing and analysis to predict human social behaviour. For example, his group created a machine that was able to autonomously predict the outcome of a negotiation or of a speed date within its very first minute (see [1] and [2]).

The main goal of social signal processing, is to enable analysis of Human behaviour by computers. For this advanced pattern recognition techniques are utilized to automatically interpret complex human behavioural patterns. In the next days, we will talk more about these techniques that are used to interpret human behaviour. Stay tuned! n_n

References:
1)I. Poggi and F. DÉrrico, "Social signals: A psychological perspective." . Springer Verlag’s Advances in Pattern Recognition series, 2011, pp. 185-225.
2)Pentland, A.: Social signal processing. IEEE Signal Process. Mag. 24(4), 108–111 (2007)
3)Curhan, J., Pentland, A.: Thin slices of negotiation: predicting outcomes from conversational
dynamics within the first five minutes. J. Appl. Psychol. 92, 802–811 (2007)
4)Ekman, P., Friesen, W.V.: Nonverbal leakage and clues to deception. Psychiatry 32, 88–106
(1969)
5) A. A. Salah, M. Pantic, and A. Vinciarelli, "Recent Developments in Social Signal Processing," in Proceedings of the IEEE International Conference on Systems, Man and Cybernetics, 2011, pp. 380-385.

Friday, October 14, 2011

Alles Auf Anfang, o la cancion para empezar tu vida

Tenia meses que queria compartir esta cancion. Es una cancion alemana de uno de mis grupos favoritos: Wir sind Helden. (Nosotros somos los heores!) . Esta cancion me encanta la melodia, es de esas cancione que me pone de buen humor escucharla, me dan ganas de bailar. Pero lo mejor que tiene esta cancion es la letra. El mensaje que yo entiendo es que debes tomar accion! Si hay cosas que no te agradan de la vida, esta en tus manos cambiarlas. Ponte las pilas. Da todo cada dia! Alles auf anfang! Da todo en este principio que viene! Venga Pumas vamos!

Aqui esta la cancion. Enjoy!


Version Alemana:


23.55: Alles auf Anfang
Du wirst zahnlos geboren und ohne Zähne gewogen
Kriegst sie bis Mitte zwanzig, schon wieder gezogen
Bist oh so verschüchtert, verzagt und vernagelt
Kein Licht dringt zu dir, so geplagt bist du, sternhageldicht
Was dich runterzieht, sind deine schweren Arme
Wer schleicht, dem wird leicht kalt, darum schleichst du ins Warme
Du nennst es Weltschmerz, ich nenn' es Attitüde
Es ist erst fünf vor zwölf und du bist schon so müde

Ihr sagt: "Kein Ende in Sicht"
Wir sagen: "Fünf vor zwölf, alles auf Anfang"
Ihr sagt: "Kein Ende in Sicht"
Wir sagen: "Fünf vor zwölf, alles auf Anfang"

Nimm deine Zähne, leg sie unter dein Kissen
Und sag der Fee du möchtest folgendes wissen:
"Warum sinkt mir mein Herz in meine schweren Beine?
Ich kann kein Ende sehen von meiner langen Leine"
Das was dich so beschwert, das sind die dicken Bären
die sie dir aufbinden, du könntest dich beschweren
Ob das von Bein haut, das wäre nun zu klären
Wenn die kleinlauten, kleinen Leute im Kleinen deutlich lauter wären

Ihr sagt: "Kein Ende in Sicht"
Wir sagen: "Fünf vor zwölf, alles auf Anfang"
Ihr sagt: "Kein Ende in Sicht"
Wir sagen: "Fünf vor zwölf, alles auf Anfang"

Ihr sagt: "Kein Ende in Sicht"
Wir sagen: "Fünf vor zwölf, alles auf Anfang"
Ihr sagt: "Kein Ende in Sicht"
Wir sagen: "Fünf vor zwölf, alles auf Anfang"

Wer "A" sagt muss auch "B" sagen
Nach dem ganzen "ABC" fragen
Wer "ach" sagt muss auch wehklagen
Wer "ja" sagt auch "ach nee" sagen

Fühlst du dich mutlos? Fass endlich Mut, los!
Fühlst du dich hilflos? Geh' raus und hilf, los!
Fühlst du dich machtlos? Geh' raus und mach, los!
Fühlst du dich haltlos? Such Halt und lass los!

Ihr sagt: "Kein Ende in Sicht"
Wir sagen: "Fünf vor zwölf, alles auf Anfang"
Ihr sagt: "Kein Ende in Sicht"
Wir sagen: "Fünf vor zwölf, alles auf Anfang"

Ihr sagt: "Kein Ende in Sicht"
Wir sagen: "Fünf vor zwölf, alles auf Anfang"
Ihr sagt: "Kein Ende in Sicht"
Wir sagen: "Fünf vor zwölf, alles auf Anfang"

Ihr sagt: "Kein Ende in Sicht"
Wir sagen: "Fünf vor zwölf, alles auf Anfang"
Ihr sagt: "Kein Ende in Sicht"
Wir sagen: "Vier vor zwölf, alles auf Anfang"
Ihr sagt: "Kein Ende in Sicht"
Wir sagen: "Drei vor zwölf, alles auf Anfang"
Ihr sagt: "Kein Ende in Sicht"
Wir sagen: "Zwei, eins, auf die Zwölf"



Version En Espa~ol!

23.55: Listos para empezar!
Naciste sin dientes y sin ellos te pesaron ,
Haz que lleguen hasta tus veinti-tantos
Con buena fe arragantelos.
Estas tan intimidado, tan fracasado y atrapado,
Ningun rayo de luz llega a ti, estas tan molesto

Lo que a ti te cansa, son tus brazos pesados,
quien anda a hurtillas, a escondidas, estara un poco friolento, por eso entras tu al calor a escondidas.
Tu lo llamas "Cansancio de estar vivo", yo lo llamo 'Actitud'
Ya son 5 para las doce, y tu ya estas cansado

Ustedes dicen: "No se ve el fin"
Nosotros decimos: "Son las cinco para las doce, vamos a dar el todo en este nuevo dia"
Ustedes dicen: "No se ve el fin"
Nosotros decimos: "Son las cinco para las doce, vamos a dar el todo en este nuevo dia

Toma tus dientes y dejalos debajo de tu cojin,
y preguntale al raton de los dientes, todo lo que quieras saber:
"Por que mi corazon se cae hasta mis pesadas piernas?
No puedo ver el fin desde mi larga linea"
Lo que a ti te pesa es que te estan haciendo pendejo,te puedes ir a quejar,
talvez sea un problema con la piel de tu pierna, se puede eso aclarar,
cuando la gente chiquita y docil se une, es mucho mas fuerte.

Ustedes dicen: "No se ve el fin"
Nosotros decimos: "Son las cinco para las doce, vamos a dar el todo en este nuevo dia
Ustedes dicen: "No se ve el fin"
Nosotros decimos: "Son las cinco para las doce, vamos a dar el todo en este nuevo dia

Ustedes dicen: "No se ve el fin"
Nosotros decimos:"Son las cinco para las doce, vamos a dar el todo en este nuevo dia
Ustedes dicen: "No se ve el fin"
Nosotros decimos: "Son las cinco para las doce, vamos a dar el todo en este nuevo dia

Quien dice A tiene tambien que decir B
Pide por todo el alfabeto
Quien dice "ahh": tambien debe empezar a llorar
Quien dice "si" debe tambien decir "duh!, obvio!"

te sientes sin animos? Vamos animate!
Te sientes sin ayuda? Vamos sal a ayudar a la gente!
Te sientes impotente? Vamos sal y hazte cargo!
Te sientes desorientado? Vamos sal y orientate!

Ustedes dicen: "No se ve el fin"
Nosotros decimos: "Son las cinco para las doce, vamos a dar el todo en este nuevo dia
Ustedes dicen: "No se ve el fin"
Nosotros decimos: "Son las cinco para las doce, vamos a dar el todo en este nuevo dia

Ustedes dicen: "No se ve el fin"
Nosotros decimos: "Son las cinco para las doce, vamos a dar el todo en este nuevo dia
Ustedes dicen: "No se ve el fin"
Nosotros decimos: "Son las cinco para las doce, vamos a dar el todo en este nuevo dia

Ustedes dicen: "No se ve el fin"
Nosotros decimos: "Son las cinco para las doce, vamos a dar el todo en este nuevo dia
Ustedes dicen: "No se ve el fin"
Nosotros decimos: "Son las cinco para las doce, vamos a dar el todo en este nuevo dia

Ustedes dicen: "No se ve el fin"
Nosotros decimos:"Son las cinco para las doce, vamos a dar el todo en este nuevo dia
Ustedes dicen: "No se ve el fin"
Nosotros decimos: dos, uno...vamos por el doce!




Algo que me agrado de hacer esta traduccion, fue que aprendi una frase en aleman nueva:
" jmd. einen Bären aufbinden", es como bromear con alguien, yo lo tome como vacilarlo, hacerlo pendejo etc. Se me hace una frase rara porque Bären es oso. O.o

Thursday, October 06, 2011

El arte de negociar, y la diferencia de generos




El dia de hoy mi universidad invito a la autora de Ask For It: How Women Can Use the Power of Negotiation To Get What They Really Want y Women Don’t Ask:The High Cost of Avoiding Negotiation and Positive Strategies for Change, Sara Laschever. Pense en hacer un peque~o post respecto a lo que aprendi en esta platica y compartirlo con mis lectores, porque creo que para muchos (no solo mujeres) el pedir por las cosas es un acto dificil.

Dentro de la platica, Sara hablo de como los hombres ven el negociar muy diferente a como lo ven las mujeres. Para los hombres. negociar es algo agradable es como un juego de baseball donde debes tener estrategias. Para las mujeres, el negociar es algo tedioso, algo horrible, como ir al dentista. La autora dijo que esta diferencia de percepcion, radicaba en la diferencia de crianza que existia entre ni~os y ni~as. A las nenas, usualmente se les da juegos que involucran el cuidado de los demas: les dan bebes de juguete, sets de cocina etc. Mientras que a los ni~os, se les dan juegetes donde tienen que explorar su propio ingenio para salir adelante: se les da sets de trenes, donde deben construir rutas y ver como saltar obstaculos etc. A las ni~as tambien se les suele dar tareas diferentes a la de los ni~os. A las ni~as las tareas que se les da son relacionadas con cuidar bebes o a sus herman@s peque~os, ayudar en la cocina. Usualmente todas las tareas en las que se involucran a las nenas hay un adulto supervisando, mientras que a los ni~os, las tareas que se les asigna en el hogar tienen que ver con lavar el coche, quitar la nieve de la acera, arreglar el jardin, sacar la basura etc. Los ni~os reciben menos supervision que las ni~as en las tareas que se les da, y en muchos casos a los ni~os se les paga por el trabajo que ejecutaran: hey te dare 10 pesos si lavas el coche etc. Desde chicos, los ni~os aprenden a negociar las cosas, porque comienzan a decirle a sus padres: Solo 10 pesos? Pero es un auto grande y ademas lo aspirare, dame mejor 15 pesos! Mientras que las ni~as se acostumbran a hacer sus quehaceres por amor. "Por amor cuidare a mis hermanos."
Adicionalmente la sociedad, ve mal a las mujeres demandantes, mandonas, e interesadas en el dinero
Estas cosas provocan que cuando crezcan, los hombres y las mujeres tengan muy distintos sentimientos respecto al acto de negociar. Esto explica porque, mientras el 65% de los hombres pide un incremento de salario, solo el 12% de las mujeres lo hace.
El no negociar o pedir las cosas, hace que uno tenga grandes perdidas. Porque la persona que pidio las cosas, tiene ya un mejor CV que la persona que no pidio nada. La autora hablo de casos, donde los hombres pedian a su Universidad dinero para asisitir a conferencias. La Universidad les daba el dinero y los hombres hacian grandes conexiones por haber podido asistir. Las mujeres, como nunca preguntaron si era posible que la universidad les pagara el viaje, perdian la oportunidad de asisitir a la conferencia y expandir sus horizontes.

la autora hablo de verios puntos para mejorar la negociacion. Algunos de ellos son:
  • Asume que TODO es negociable
  • Piensa que el mundo es tu ostia ( Tu tesoro). Todo es una oportunidad.
  • Vuelvete mas chingona. ( crea conexiones con gente que esta en el poder, estudia una segunda carrera para tener mejor CV, obten diferentes asesores, gente que te puede dar consejos)
  • Haz tu investigacion (Obten informacion de cuanto puedes pedir, hay recurso en internet que te muestran salarios promedios de diferentes compa~ias, pregunta con tus amistades.Es importante estar bien informado)

Por ultimo, algo que dijo la autora que me gusto, es que si aceptas un mal salario, es aceptar que eres chafa. Es como el vino, usualmente si ves un vino barato que cuesta 20 pesos, no esperas mucha calidad de el, en cambio si ves un vino de 200 pesos, es probable que consideres que es de mucha mejor calidad y sabor. Entonces cuando aceptas salarios bajos, estas comunicando algo de ti, estas diciendo que eres el vino de mala calidad de 20 varos. Lo cual no es algo que quieres! Acepta siempre buenos tratos de buena calidad. Tu lo vales! ( Ja comercial loreal ;)

Y algo curioso que dijo la autora, es que para poder persuadir a las personas, es importante que la mujer sea amigable. (Esto por lo mismo que se menciono anteriormente, que la sociedad ve mal que la mujer sea mandona y agresiva).

Por ultimo, me gustaria escribir sobre el consejo que uno de mis amigos me dio, respecto a pedir cosas: La persona a quien le pediras X cosa, es un adulto que sabe decir NO. Entonces si no peude dartelo, sabe decir NO. no tienes por que preocuparte, no es una situacion incomoda para la otra persona. Y si lo pides, estas mejor que si no lo pides, porque en el peor de los casos, estas donde empezaste.

Friday, July 01, 2011

Getting Images laid (pause) over a video in android

This post is a short tutorial on how to overlay images on video in android. I created this tutorial, after making an android application that plays a video and with certain user interactions displays images on top of the video. This Image-Video effect can also be achieved through action script, but in this tutorial we avoid any extra programming tools and stick to working with the android API.

Before we begin, we need to giver a quick overview of concepts:

Most of the user interface components on Android are Views. A View represents a rectangular area on the screen and it is responsible for drawing and event handling. The ImageView class displays an arbitrary image, such as an icon. The VideoView class displays a video file. The ViewGroup class is considered a special view that can contain other views (called children.) This class is the base class for layouts.

In Android, a layout holds all the elements that appear to the user, and defines where they will be placed. The layout can be declared in an XML file or can be programmatically defined by creating View Objects. A particular type of layout is RelativeLayout. This Class holds the concept that each component in the interface can be described in relation to each other or to its parent.

The overall idea is that the image on video overlay can be accomplished by using RelativeLayout and placing the VideoView as the first child of the RelativeLayout and the ImageView as the second child. This way in the camera preview, the ImageView will appear to be "on top of" the VideoView.

The step-by-step instructions are as follows:

1. In Eclipse, create a Simple Android Project From Scratch (Make sure to have created a main activity).

2. Under the res folder in your project go to the drawable folder (if you don't have a folder titled "drawable" in res, create it) and add all of the images you plan on working with there.

3. Add the video or videos you plan on working with to the SD memory card of your android phone. (This can be done by connecting your phone via USB to your PC and on the phone, selecting "notifications", then "USB connected", and in the new window that appears clicking: "Turn on USB storage". After a few seconds a new removable disk should appear on your PC. Copy to it your videos. The video format of my videos was mp4)

4. Back in your android project in your layout folder, add a new xml file with the name of your choice (for example video_over_image.xml) .In this xml we will define the elements and the layout of our application. For this particular application, we want the following layout:
A text-box in the upper part of the window, where the user types the name of the video they wish to play. The space below the text-box is where the video will be displayed.
The image overlaid on the video will appear on the upper portion of the video. (But it is possible to place it wherever one desires).
Our XML file to accomplish this layout is as follows:


<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">

<TextView android:id="@+id/label"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Type video name here:" />
<EditText
android:id="@+id/edittext"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>

<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">

<Button android:id="@+id/topBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Top"
android:layout_centerHorizontal="true">
</Button>

<VideoView android:id="@+id/surface_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>

<ImageView android:id="@+id/overlayImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"

android:layout_below="@+id/topBtn"
/>

</RelativeLayout>

</LinearLayout>



An interesting point to notice about this layout is that we added a dummy button to it. Because the video is defined right after this dummy button, the video will completely "cover" the button, so it will not appear on the interface. This button helps in positioning our image; Our image is set relative to this button. In this case, because we sought for the image to appear in the "mid-top" portion of the video the image's layout was set to be below this button. It is also important to note, that the image was declared after the video, because this permits the image to be displayed "on top of" the video.


5. In our java activity file in the onCreate method, we now need to establish that we will be using this layout. We also need to establish a listener for the textbox, which after the user has typed the name of the video to play and pressed "enter" will start playing the desired video. Furthermore it is also necessary to establish what images will be overlaid and when that will occur.
To facilitate this example, we will establish that when the user types 1, video A (which should already be on the phone's SD card) will be played and image c1 will be overlaid on the video. Similarly, when the user types 2, video B will be played and image c2 will now be overlaid on the video. We will also add some effects to the image, in specific alpha blending.
In the following, we will present all the code to accomplish this task and subsequently review each part of it:



package com.example.android.videooverimage;


import android.app.Activity;
import android.media.MediaPlayer;
import android.media.MediaPlayer.OnCompletionListener;
import android.os.Bundle;
import android.util.Log;
import android.widget.MediaController;
import android.widget.VideoView;
import android.net.Uri;
import android.widget.EditText;
import android.view.KeyEvent;
import android.view.View.OnKeyListener;
import android.view.View;
import android.content.res.Resources;
import android.widget.ImageView;



public class VideoOverImageActivity extends Activity
{



public VideoOverImageActivity()
{

}


public void onCreate(Bundle icicle)
{

super.onCreate(icicle);
setContentView(R.layout.video_over_image_activity);
final EditText edittext = (EditText) findViewById(R.id.edittext);

edittext.setOnKeyListener(new OnKeyListener()
{
public boolean onKey(View v, int keyCode, KeyEvent event)
{
// If the event is a key-down event on the "enter" button
if ((event.getAction() == KeyEvent.ACTION_DOWN) && (keyCode == KeyEvent.KEYCODE_ENTER)) {
// Perform action on key press

int aInt=0;
try
{
aInt = Integer.parseInt(edittext.getText().toString());
}
catch (NumberFormatException e)
{
Log.e("debug","Error finding Image: "+e.getMessage());

}

VideoView videoHolder = (VideoView) findViewById(R.id.surface_view);
MediaController mc=new MediaController(VideoOverImageActivity.this);
Boolean returnValue=true;

switch (aInt)
{

case 1:


startPlaying(videoHolder,mc,"file:///sdcard/video1.mp4",0);
break;

case 2:
startPlaying(videoHolder,mc,"file:///sdcard/video2.mp4",1);
break;

default:
returnValue=false;
break;

}


return returnValue;


}

return false;
}
});

}

public void startPlaying(VideoView videoHolder,MediaController mc,String nameVideo, int song)
{

Resources res = VideoOverImageActivity.this.getResources();


ImageView image = (ImageView) findViewById(R.id.overlayImage);

try
{
R.drawable.class.getField("b" + song).getInt(0);
image.setImageDrawable(res.getDrawable(R.drawable.class.getField("b" + song).getInt(0)));
image.getDrawable().setAlpha(55);
}
catch (Exception e)
{
Log.e("debug","Error finding Image: "+e.getMessage());

}

videoHolder.setMediaController(mc);
videoHolder.setVideoURI(Uri.parse(nameVideo));
videoHolder.requestFocus();
videoHolder.start();

videoHolder.setOnCompletionListener(new OnCompletionListener()
{
public void onCompletion(MediaPlayer arg0)
{
try
{
Log.e("debug","MediaPlayer seek to 0...");
arg0.seekTo(0);
Log.e("debug","MediaPlayer start...");
arg0.start();
Log.e("debug","MediaPlayer started");
}

catch(Exception ex)
{
Log.e("debug","MediaPlayer error: "+ex.toString());
}
}
});



}


}