Saturday, January 30, 2016

Unicorns

Unicorn is legendary and mythical animal with single pointed horn. It was depicted as a creature in arts and crafts of all civilizations.

Uniforns or narwhals are startup companies whose evaluation exceeds one billion dollars. Unicorns are supposed to be rare animals, however there are around two hundred. Top unicorns are uber, xioami, airbnb, palantir and snapchat. Uber is worth sixty two billion dollars now. Decacorns are companies whose evaluation exceeds ten billion dollars and they include dropbox and pinterest.

References
Unicorn
Unicorns

Thursday, January 28, 2016

Next to Pearls


Reading further to Programming Pearls

  1. Software Requirements and Specifications by Michael Jackson
  2. Conceptual Blockbusting by James L Adams
  3. How to solve it by Polya
  4. Code Complete by Steve McConnell
  5. Rapid Development by Steve McConnell
  6. Project Survival Guide by Steven McConnell
  7. Science of Programming by David Gries
  8. Practice of Programming by Kernigan and Pike
  9. Medical Detectives by Berton Rourche
  10. Hints for Computer System Design by Butler Lampson
  11. How to Lie with Statistics by Darrel Huff
  12. Innumeracy : Mathematical illiteracy and it's consequences by John Allen Paulo
  13. Data Structures and Algoritms by Aho Hopcroft Ullman
  14. Introduction to Algorithms by Corman, Leiserson, Rivest
  15. Mythical Man Month by Fred Brooks
  16. The Art of Computer Programming by Donald Knuth
  17. Algorithms by Robert Sedgewick
  18. Mathematical theory of communication by Claude Shannon
  19. Literate Programming by Donald Knuth

Sunday, January 24, 2016

Ballot problem

In an election where a candidate gets p votes and other candidate gets q votes and p > q, the probability that the first candidate maintains the lead throughout the counting procedure is (p-q)/(p+q).

It was first published by W.A. Whitworth in 1878 and later rediscovered by Joseph Louis Francois Bertrand in 1887.


Sources
Bertrand's ballot theorm
Ballot problem solution

Friday, January 22, 2016

P/E ratio

P/E ratio means price of a stock of company divided by earnings per share (EPS).  It is the amount of money share holders want to pay for earning one dollar money. A good P/E ratio is between 15 to 25. Comparing P/E ratios of companies in same field is meaningful. S/W or technology companies may have higher P/E whereas old stable industries may have lower P/E value.

If it is more, it may mean either market is optimistic and thinks there is risk or there is no growth for the company or it may mean overvalued than it is worth. If it is less, then market is pessimistic about the the company or it may mean it is undervalued than it is worth in reality.

Price = Earnings * P/E ratio.
Stock price increases either because the real earnings increased or because the market perception caused the multiple (P/E) to increase.

If a company acquires other company with higher P/E, then it prefers cash purchase. If a company acquires other company with lower P/E, then it prefers to do stock purchase.

References
investopedia P/E
wikipedia P/E

Wednesday, January 20, 2016

PIN codes

PIN code stand for Postal Index Number code. It was introduced on independence day in 1972. It is six digits long. The first digit represents a zone and it is typically one or more states. There is one functional zone for army and military purpose. The first three digits together represent a geographical region or sorting facility at a main post office. Fourth digit represents the delivery route and zero digit means it is in main area of the post office. Fifth and sixth digits represent the delivery post office.

PIN codes start from North most states around Delhi and head south along the west coast in increasing order and then they head north along the east coast after reaching the south and head west and end in central India.
  • 1 - Delhi, Haryana, Punjab, Himachal Pradesh, Jammu and Kashmir, Chandigarh
  • 2 - Uttar Pradesh, Uttarakhand
  • 3 - Rajasthan, Gujarat, Daman and Diu, Dadra and Nagar Haveli
  • 4 - Goa, Maharashtra, Madhya Pradesh, Chhattisgar
  • 5 - Andhra Pradesh, Karnataka, Telangana
  • 6 - Tamil Nadu, Kerala, Puducherry, Lakshadweep
  • 7 - Odisha, West Bengal, Arunachal Pradesh, Nagaland, Manipur, Mizoram, Tripura,Meghalaya, Andaman and Nicobar Islands, Assam, Sikkim
  • 8 - Bihar, Jharkhand
  • 9 - Army Post office (APO) and Field Post office (FPO)

References
wikipedia PIN codes

Monday, January 18, 2016

zip codes

ZIP stands for zone improvement plan. There are 41,716 codes in United States of America.

Robert A. Moon, a postal employee, noted that rail based and address based delivery systems would not scale and fought for twenty years for number based systems what was to become the ZIP code with three digits. He divided the country into 900 regions.  H. Bently Hahn added fourth and fifth digits and persuaded the panel to go with five digits and credited with new system that revolutionized the postal delivery. It is further extended to nine digits or zip+four system in 1983.

Before zip codes were invented, workers sorted mail in some special mail cars in trains. United states post office (USPS) lost lot of trained personal during wars. Volume of mail was increasing rapidly - 43 million mails every week or 30 billion mails annually. Planes started carrying more mail than trains did.

The numerical system made easy transition to mechanized processing from manual sorting. However it took long time for people to start writing zip code along with mail address. United states post office (USPS) came up with cartoon character Mr. ZIP and campaigned that including zip code makes mailman travel with high speed. Mr. ZIP character was originally designed by Howard Wilcox of Cunnigham and Walsh Ad Agency for use by a Newyork bank to use in banking by mailing campaign. AT&T purchased the design and gave to USPS without the cost.

Some ZIP codes are unique to single high volume address like 20500 for white house and 72716 for Walmart headquarters. They are 2122 such codes. Some ZIP codes are for military, diplomat offices and embassies. There are 532 such codes. Some ZIP codes are used for solely post box addresses in some cities. There are 5122 such codes. Rest of the ZIP codes are based on geographical location. They are 29773 such codes.  Wealthiest zip code is 90210 for Beverly Hills, CA.

First digit denotes a state or group of states. The digit 9 is shared by west coast states California, Oregon and Washington, Alaska, Hawai and several other islands. Second and third digits denote a region or large city in those states. Together the first three digits denote sectional facility center or the main sorting and distribution center for an area. Fourth and Fifth digits denote group of addresses within a region. ZIP codes can cross state and other political boundaries. ZIP codes start on east coast and increase southwards and continue heading towards northward and westward east of Mississippi river, southward west of Mississippi river and northward on west coast.

ZIP codes are also used for gathering statistics like cenus data, marketing campaigns to identify purchase patterns, income patterns and demographics and as key in several online database systems.

References:
ZIP code
Robert Moon
H. Bently Hahn
wikipedia Mr. ZIP
USPS Mr. ZIP
Zip code statistics

Tuesday, January 12, 2016

Abraham Lincoln


Abraham Lincoln is one of the greatest american presidents. He led the nation through the civil war and kept the union with all possible ways he can - with diplomacy, with war and with power.

He changed parties but he campaigned and fought for abolition of slavery all the time; Whigs 1834-1854, Republican 1854-1864 and National Union 1864-1865.

He is still remembered for the following two milestone events.
  • Emancipation Proclamation in 1863, an executive order by president to change the federal legal status of slaves in southern states to free.
  • Thirteenth amendment that completed abolishing slavery in all states except as punishment for a crime. Senate passed april 18th, 1864 and house passed it after one unsuccessful vote on jan 31st, 1865.
Similar ammendments were attempted by Arthur Livermore in 1818 and John Quincy Adams in 1839.

References
Abraham Lincoln
Thirteenth Ammendment

Sunday, January 10, 2016

Fisher's Principle of gender ratio

Ronald Fisher in his 1930 book "The genetical theory of natural selection" explains why the male to female ratio in most species is 1:1. It is one of the most celebrated principles in evolutionary biology. It may be wrongly attributed to him and scientists before him may knew it. He popularized it with his book and attracted the attention of wider community. 

If a community or group of animals has a tendency to produce offspring of one sex, natural selection prefers the representative parents who have that tendency in the community when the population of that sex is less compared to that of other sex or it prefers different kind of parents otherwise. Once the ratio is achieved, it can swing to other side again and the process repeats.

Fisher is a British scientist and biologist. Works of him along with British geneticist JBS Haldene and American geneticist Sewell Wright is considered to be founded the discipline of population genetics. He did several other contributions to biology like fisherian runway that explains why male peacocks and other animals have natural decorations.

References
Population Genetics
Fisher's principle
Ronald Fisher

Saturday, January 9, 2016

Mount Rushmore

Mount Rushmore is a national memorial located in blackhills in Keystone, South Dakota, US. It has pictures of four presidents, George Washington, Thomas Jefferson, Theodore Roosevelt and Abraham Lincoln, sculpted into a granite rock hill. 

It was done by danish american Gutzon Borglum and his son, Lincoln Borglum. The carving starred in 1927 and completed in 1941. It was done with the support from president Calvin Cooledge and senator Peter Norbeck. 

See Mount Rushmore wikipedia link



Thursday, January 7, 2016

Great circle distance

Earth is sphere and more accurately a spheroid. Calculating distance between two points on earth is different to calculating the distance between the two points on flat surface. The Circle that connects the two points with center of the sphere as the center is called great circle. The distance between the points is the length of the arc between the points on great circle.

Approximate method:
Circumference of earth at equator is 40,076km and we have 360 degrees in circle and so each degree of longitude at equator is about to 111.32km or 69 miles. The distance between two longitude lines decrease from the equator to poles.

Around 30 degrees north or south from the equator, one degree of longitude is about 96.41km. Around 45 degrees north or south of equator, one degree of longitude is 78.71km. Around 60 degrees, one degree of longitude is 55.66km. Around 75 degrees north or south of equator, one degree of longitude is 28.82km. Around 90 degrees from the equator, that will be poles and one degree of longitude is zero distance.  

However the distance between two lines of latitude stay almost same anywhere from equator to poles. Small difference is because of the shape of the earth. One degree of latitude is 110.57km at equator and 111.69km at poles.

Once we have longitudinal distance and latitude distance between two points, we can compute the distance between two points. The Pythagoras theorem can be used here.

Using cosine law:
Suppose the geographical latitude and longitude of two points on the earth are a1, a2 and b1. We can compute the central angle between them is given by the spherical law of cosines
c = arccos(sin(a1).sin(a2) + cos(a1).cos(a2).cos(|b2-b1|))
The distance d, or the arc length on a sphere of radius r formed by spherical angle c in radians  = r. c; 

Using haversine law:
Alternatively if we know the linear distance between the points as w and using sine law, length of arc on great circle can be calculated as 2*r*arcsin(w/(2.r)).

References
Lat Lang Story
Great circle distance using cosine law
Great circle distance using sine law
Longititude and latitude measuring

Wednesday, January 6, 2016

California King


Twin or single - 39 inches x 75 inches = 99 cm x 191 cm = 3' 3'' x 6' 3''
Twin XL - 39 inches x 80 inches = 99 cm x 203 cm = 3' 3'' x 6' 8''
Three quarters - 48 inches x 75 inches = 122 cm x 191 cm = 4' x 6' 3''
Full or Double - 54 inches x 75 inches  = 137 cm x 191 cm = 4' 6'' x 6' 3''

US Queen or UK king - 60 inches x 80 inches = 152 cm x 203 cm = 5' x 6' 8''
US King or UK Superking - two twin xl - 76 inches x 80 inches = 193 cm x 203 cm = 6' 4'' x 6' 8''
Cal King - 72 inches x 84 inches = 183 cm x 213 cm = 6 foot x 7 foot

References;
Mattress dimensions
* Bed size
* Bed sizes

Monday, January 4, 2016

Ethernet MTU limits TCP MSS


TCP Maximum segment size (MSS) or payload in TCP packet is typically 1460 bytes only!

Length of IP packet is capped by 16 bytes field in IP header which itself is 20 bytes and so MTU for protocols on top of IP is = 2^16 - 20 = 65515 bytes and it is much larger than 1460 bytes.

TCP implementations want to use lowest mss that can avoid the packet fragmentation over the internet.

Maximum transfer unit (MTU) is the size of the largest payload a packet can contain after subtracting the header and other metadata information needed to transmit the payload.

Ethernet frame size is 1530 bytes, but ethernet MTU is only 1500 bytes. Payload is preceded by ethernet header and is followed by Frame check Sequence(FCS).
* preamble 7 bytes, start frame 1 byte
* header 14 to 18 bytes - source addr, dst addr, optional 802.1 vlan tag and payload type.
* FCS - 4 bytes.

Subtracting 20 bytes for IP header and 20 bytes for TCP header, 1500 - 40 = 1460 bytes.

References
* Ethernet frame