Ramblings from a Bihari!

Just another WordPress.com weblog

Information asymmetry

Once upon a time there was a village in which there lived many married couples. There were certain qualities about this village, though, that made this village unique: Whenever a man had an affair with another man’s wife, every woman in the village got to know about the affair, except his own wife. This happened because the woman who he had slept with talked about their affair with all the other women in the village, except his wife. Moreover, no one ever told his wife about the affair. The strict laws of the village required that if a woman could prove that her own husband had been unfaithful towards her, then she must kill him that very day before midnight. Also, every woman was law-abiding, intelligent, and aware of the intelligence of other women living in that village.
You and I know that exactly twenty of the men had been unfaithful to their wives. However, as no woman could prove the guilt of her husband, the village life proceeded smoothly.
Then, one morning, a wise old man with a long, white beard came to the village. His magical powers, and honesty was acknowledged by all and his word was taken as the gospel truth. The wise old man asked all villagers to gather together in the village compound and then announced: “At least one of the men in this village has been unfaithful to his wife.” Questions: 1. What happened next? 2. And what this got to do with stock market crashes? Answer 1: After the wise old man has spoken, there shall be 19 peaceful days followed by a massive slaughter before the midnight of the 20th day when twenty women will kill their husbands. Proof: We will use backward thinking for the proof. Indeed, the very purpose of this post is to demonstrate the utility of the backward thinking style. Let’s start by assuming that there is only one unfaithful man in the village – Mr. A. Later, we shall drop this assumption. Every woman in the village except Mrs. A knows that he is unfaithful. However, since no one has told her anything, and she remains blissfully ignorant. But only until the old man speaks the words, “At least one of the men in this village has been unfaithful to his wife.” The old man’s words are news only for Mrs. A, and mean nothing to the other women. And because she is intelligent, she correctly reasons that if any man other than her own husband was unfaithful, she would have known about it. And since she has no such knowledge in her possession, it must mean that it’s her own husband who is unfaithful. And so, before the midnight of the day the old man spoke, she must execute her husband. Now, let’s assume that there were exactly two unfaithful men in the village – Mr. A and Mr. B. The moment the old man speaks the words, “At least one of the men in this village has been unfaithful to his wife,” the village’s women population gets divided as follows:
Every woman other than Mrs. A and Mrs. B knows the whole truth;
Mrs. A knows about philanderer Mr. B, but, as of now, knows nothing about  her own husband’s unfaithfulness, so she assumes that there is only one  unfaithful man – Mr. B – who will be executed by Mrs. B that night; and Mrs. B knows about philanderer Mr. A, but, as of now, knows nothing about her own husband’s unfaithfulness, so she assumes that there is only one unfaithful man – Mr. A – who will be executed by Mrs. A that night.  
As the
midnight of day one approaches, Mrs. A is expecting Mrs. B to execute her husband, and vice versa. But, and this is key, none of them do what the other one is expecting them to do! The clock is ticking away and passes midnight and day 2 starts. What happens now is sudden realization on the part of both Mrs. A and Mrs. B, that there must be more than one man who is unfaithful. And, since none of them had prior knowledge about this other unfaithful man, then it must be their own respective husbands who were unfaithful! In other words, the inaction of one represents new information for the other. Therefore, using the principles of inductive logic requiring backward thinking, both Mrs. A and Mrs. B will execute their respective husbands before the midnight of day 2. Now, let’s assume that there are exactly three unfaithful men in the village- Mr. A, Mr. B., and Mr. C. The same procedure can be used to show that in such a scenario, the wives of these three philandering men will kill them before the midnight of day 3. Using the same process, it can be shown that if exactly twenty husbands are unfaithful, their wives would finally be able to prove it on the 20th day, which will also be the day of the bloodbath. Answer 2: Connection with Stock Market Crashes If you replace the announcement of the old man with that provided, by say,  SEBI, the nervousness of the wives with the nervousness of the investors,  the wives’ contentment as long as their own husbands weren’t cheating on  them with the investors’ contentment so long as their own companies were  not indulging in fraud, the execution of twenty husbands with massive  dumping of stocks, and the time lag between the old man’s announcement and  the killings with the time lag between the old man’s announcement and the  market crash, the connection between the story and market crashes becomes  obvious. Information Asymmetry One of the most interesting aspects about the story is the role of information asymmetry. You and I knew that there were exactly twenty unfaithful men in the village. We had complete information about the number of unfaithful men in that village but not their identity. On the other hand, every woman in the village knew the identity of at least nineteen unfaithful men. For example, if you were Mrs. A, you would have known about nineteen unfaithful men, but not about your own husband’s unfaithfulness. And, if you were one of the women whose husband was faithful, then you’d know the identity of twenty unfaithful men. But the old man did not say that there were twenty unfaithful men in the village. All he said was that there was at least one unfaithful man in the village. So, his statement, did not add anything to the knowledge of any individual woman because each of them knew of at least nineteen unfaithful men! And yet, his statement caused the bloodbath after twenty days! The lesson is simple: It’s not necessary for any new information to cause havoc in the stock market. Sudden realizations about the stupidity of  gross overvaluations and dubious accounting practices followed by some  companies in bubble markets can and do occur simultaneously in the minds  of the crowd. And that sudden realization can cause markets to crash!  

September 21, 2007 Posted by | Life Around Code | Leave a comment

Another bad mark on My Image in Boss’s Mind……:(

Another bad incident……

For the whole fraternity of indian cricket fans the 6 sixes on Yuvi against Broad is like immaculate piece of gift. But for me it went into another embarrasing laps of working day….

After the six sixes me and my lovely brothers got highly spirited for india and bought the same spirit we are having since our college days…… IMPERIAL BLUE with Thumps UP(SHhhhhh… my boss can forgive me for not coming to office but he will throw me out of office if he found me mixing cold drink with Whysky) …

Anyways by the end of the match i was full bottle down and not in my senses. They told me that i slept after 4 in the morning and i dont know what happened after that. But when i woke up next morning it was 5 Pm in the evening… High hangover…. Shittttt. Again not in the state of going enywhere… i know my this habit will some day take my job from me ……. God save me from the scoldings of ……….

September 21, 2007 Posted by | Life Around Code | Leave a comment

Sharing the same connection or transaction space between derby sql and java.

Think of a situation in which you want to write a stored procedure in Derby and the procedure is calling a static java method inside the same JVM. The important requirement here is that the java method is is being executed by the SQL stored procedure is modifiying some data in the database. So finally the scenario is :: SQL is modifying the data as well as the java method is also modifying the data in the same database. So one must be thinking of transaction safety…. e.g when u rollback both the changes(made by SQL and the corresponding java method) must get rollback. Following is the example…….

Trigger which calls a stored procedure.:::::


Procedure which is called by trigger and which in turn calls the static java method::::


The java method which shares the same transaction space as the Procedure which is calling it.

public static void executeTriggerLogic(String pKColName1,String pKColName2, int pKValue1, int pKValue2, String tableName,

String flag) {

String updateDashTableQry = “update “

+ tableName

+ “_dash set time = current_timestamp, flag = ‘”

+ flag

+ “‘, user_id = ‘error’ “

+ (flag.equalsIgnoreCase(“I”) ? “, inserted_time = current_timestamp”

: “”) + ” where “ + pKColName1 + ” = “ + pKValue1

+ ” AND “ + pKColName2 + ” = “ + pKValue2;String insertIntoDashTableQry =

“insert into “ + tableName + “_dash values( “ + pKValue1 + “, “ + pKValue2

+ “, current_timestamp, ‘” + flag + “‘, “

+ (flag.equalsIgnoreCase(“I”) ? “current_timestamp” : null)

+ “, ‘error’)”;

try {

Connection conn = DriverManager


String query = “select count(*) from “ + tableName + “_dash where “

+ pKColName1 + ” = “ + pKValue1 + ” AND “ + pKColName2

+ ” = “ + pKValue2;

int count = 1;

PreparedStatement ps = conn.prepareStatement(query);

ResultSet rs = ps.executeQuery();

if (rs.next()) {

count = rs.getInt(1);


if (count > 0) {System.out.println(“update query ::” + updateDashTableQry);

PreparedStatement ps1 = conn



} else {System.out.println(“insert query ::” + insertIntoDashTableQry);

PreparedStatement ps2 = conn





} catch (SQLException e) {





The most important line as per sharing the same transaction space or sharing the same connection instance between the procedure and the static java method is

Connection conn = DriverManager


You even dont need to load the Driver as in normal JDBC routine. The above is a very good example which can solve a major migration issue from a Oracle  database trigger to the Java Database(derby) trigger.



September 21, 2007 Posted by | techie stuff | 1 Comment