Bayes Theorem can be derived from the condition probability principles stated in Part 1 below.
⁃ Pr(A|B) = Pr(A and B)/Pr(B), if Pr(B) not = 0
⁃ Pr(B|A) = Pr(A and B)/Pr(A), if Pr(A) not = 0
⁃ Pr(A and B) = Pr(A|B)*Pr(B) = Pr(B|A)*Pr(A)
⁃ Pr(A|B) = Pr(B|A)*Pr(A)/Pr(B)
**Note: Pr(A and B) can be visualised with a Venn Diagram. The set that is common to two or more sets overlap, the overlapping set is the and space. Example: of 10 people that like fruit, five people like apples and four people like oranges. Two people like apples and oranges. In this case, one person likes neither apples or oranges, three people like apples but not oranges and two people like oranges but not apples.
Example: Quality and Control with Software
Suppose you have 7 programmers at your company developing Java classes. The following table describes their track record with quality:
Programmer | Proportion of development | Probability of defective class (code)
￼1 .10 .03
2 .05 .03
3 .20 .02
4 .15 .02
5 .25 .01
6 .15 .02
7 .10 .03
Suppose that the Quality and Assurance department (Q&A) reviewed classes at random and found them to be defective. What is the probability that Programmer 1 developed this defective code?
If Programming is an event, then these are seven mutually exclusive events and their union is the entire sample space. A class was only developed by one and only one of the Programmers. (We’re assuming in this case that one programmer develops one class, which usually isn’t the case since programmers work in teams, however, this example may be extrapolated to groups, i.e. group 1 develops 10% of the code with a quality rate of 97%).
Let Bi (i = 1,2, … 7) be the event that the class was developed by programmer i, and let A be the event that the class is defective. Then, for example:
Pr(B1) = .10 and Pr(A|B1) = .03
In this case we have to calculate the reversed conditional probability. That is, we need to calculate the probability that the event, B1 (probability of Programmer 1 developing the code) is from the sample space A (probability of defective code). By applying Bayes’ Theorem the formula would be:
Pr (B1|A) = Pr(A|B1)*Pr(B1) / Pr(A|B1)*Pr(B1) + Pr(A|B2)*Pr(B2) + … + Pr(A|B7)*Pr(B7)
Pr(B1|A) = (.10)(.03) / (.10)(.03) + (.05)(.03) + (.20)(.02) + (.15)(.02) + (.25)(.01) + (.15)(.02) + (.10)(.03)
Pr(B1|A) = .15
So there is a 15% probability that the defective code is from Programmer 1.
I found these notes for finite math principles to be helpful. They have to do with combinations and permutations…there are plenty of resources on the web but you may find these useful. I personally learned this stuff a long time ago but it’s always helpful to brush up on the basics. Enjoy!
Combinations and Permutations
- If the order doesn’t matter it’s a combination.
- If the order does matter it’s a permutations.
Two types of Permutations (order does matter):
- Repetition is allowed:
- Formula: n^r
- Example: a lock with ten numbers to choose from (0, 1…9) numbers with three to choose from. This would equate to 10^3 = 1,000.
- Repetition is not allowed
- Formula: n! / (n – r)!
- Example: if you were to figure out how to order 16 pool balls, the result would be 16! = 20,922,789,888,000. If however you only wanted to calculate the number of permutations required to choose 3 out of the 16 pool balls then you would have 16! / (16-3)! = 16! / 13! = 3,360
Two types of Combinations (order doesn’t matter):
* Note there will always be more permutations than combinations
- Repetition is allowed:
- Formula: (n + r -1)! / r!(n-1)!
- Example: choose three scoops of ice-cream out of five possible flavours. In this case, the result would be (5+3-1)! / 3!(5-1)! = 7! / 3!*4! = 35.
- Repetition is not allowed:
- Formula: n! / r!(n-r)! . Also known as the binomial coefficient, also known as saying, for example 16 choose 3 (choose 3 pool balls out of the 16 available).
- Example: choose 3 pool balls out of the available 16, but in this case the order does not matter. The result would be 16! / 3! X (16-3)! = 16! / 3! X (13)! = 16! / 3! X (13)! = 560.
Number of probabilities in an Event
The number of probabilities in an event is:
Pr(E) = [Number of outcomes in E] / N
Where E is the event and N is the sample space.
Example: there are 8 white balls and two green balls in an urn. If you were to choose 3 balls out of the urn, what are the chances that they are all white balls?
Solution: number of white balls are 8. Since order doesn’t matter and repetition is not allowed, the formula would be for a combination without repetition: C(8,3) = 56. The probability that this event would occur would have to be divided by the sample space, which is C(10,3). So the result would be C(8,3) / C(10,3) = 7/15.
Calculating ‘at least’ questions (these are always on quizzes and tests and are brain teasers)
Two possible ways may be used to calculate ‘at least’ questions. For example, what is the probability of selecting one green ball out of three selected from an urn that has 2 green balls and 8 white balls.
One: use the multiplication and addition principles
- Event for first green ball is C(2,1) X C(8,2).
- Event for second green ball is C(2,2) X C(8,1).
- Probability for both events are added: C(2,1) X C(8,2) + C(2,2) X C(8,1).
- Divide by sample space using probability of an event formula: C(2,1) X C(8,2) + C(2,2) X C(8,1) / C(10,3) = 8/15
Two: use the complement rule
- Complement rule: Pr(E) = 1 – Pr(E’)
- Since the probability of selecting ‘all three balls are white’ = C(8,3) / C(10,3) = 7/15.
- The event ‘at least one ball is green’, is F.
- The complement of F, F’, is equal to E. Therefore E = F’.
- So by the complement rule, Pr(F) = 1 – Pr(F’) = 1 – Pr(E) = 1 – 7/15 = 8/15.
Pr(E|F). Sample space, F, is restricted. Written as Pr(E|F) = P(E and F) / Pr (F)
If E and F are independent, then Pr(E and F) = Pr(E) * Pr(F). Example: rolling dice, one roll has no affect on the other.
May also be expressed as Pr(E|F) = Pr(E) and Pr(F|E) = P(F). This is obtained from the above by: Pr(E|F) = Pr(E and F)/Pr(F) = Pr(E)*Pr(F)/Pr(F), so Pr(F) cancels out leaving Pr(E|F) = Pr(E)
A set of events are independent from each other if Pr(E1 and E2 and E3 and … En) = Pr(E1 * E2 * E3 … En). For example, a stereo has the probability of 2% of having a defective CD, 3% of having defective amplifier and 7% of defective speakers. Let these be events E, F and S^2, respectively. Then the chance of the system not being defective is E’, F’, S’^2. So the result would be Pr(E’) * Pr(F’) * Pr(S’)^2 = .98*.97*.93^2 = .822.
I have been playing around with Python on my Mac OSX Lion, version 2.7. (If you need to confirm the version just type using your Terminal:
$ Python -version
I came up with this handy script to check the ABV (alcohol percentage) for Beer or Wine. It’s a handy script if you’re into home brewing. It also helped get me going on how simple it is to use Python and it’s also handy for prototyping different algorithms before getting to some serious coding in another language!
By the way, you may use this script without restrictions, but if I ever meet you buy me a beer, preferably a DIPA :=)).
* "THE BEER-WARE LICENSE" (Revision 42):
* wrote this file. As long as you retain this notice you
* can do whatever you want with this stuff. If we meet some day, and you think
* this stuff is worth it, you can buy me a beer in return Poul-Henning Kamp
# Program used to calculate the alcohol percentage by volume in beer.
# @ Greg Werner
# Variable definitions for command prompt inputs. Includes conversion from strings to floats
og = raw_input('Please enter your Original Gravity reading: ')
o = float(og)
tempog = raw_input('Please enter the temperature, in F, when obtaining your Original Gravity: ')
tempOG = float(tempog)
fg = raw_input('Please enter your Final Gravity reading: ')
f = float(fg)
tempfg = raw_input('Please enter the temperature, in F, when obtaining your Final Gravity: ')
tempFG = float(tempog)
# Function definition for original gravity and final gravity parameters with three floating point positions.
def abv(o, f):
x = '%.3f' % (o)
y = '%.3f' % (f)
og = float(x)
fg = float(y)
# Conditions for adjusting original y final gravity readings according to temperature in F.
if tempFG <= 69:
fg = fg + 0
elif tempFG >= 70 and tempFG <= 76:
fg = fg + 0.001
elif tempFG >= 77 and tempFG <= 83:
fg = fg + 0.002
elif tempFG >= 84 and tempFG <= 94:
fg = fg + 0.003
elif tempFG >= 95 and tempFG <= 104:
fg = fg + 0.004
fg == 105
fg = tempFG + 0.007
if tempOG <= 69:
og = og + 0
elif tempOG >= 70 and tempOG <= 76:
og = og + 0.001
elif tempOG >= 77 and tempOG <= 83:
og = og + 0.002
elif tempOG >= 84 and tempOG <= 94:
og = og + 0.003
elif tempOG >= 95 and tempOG <= 104:
og = og + 0.004
og == 105
og = og + 0.007
abv = ((1.05 * (og - fg))/ fg) / 0.79 * 100
return '%.3f' % abv
ABV = float(abv(o, f))
# Print results for ABV calculation.
if ABV <= 5.00:
print ('Your beer has an alcohol content of ' + str(ABV) +'. You have a low alcohol beer.')
elif ABV >= 5.01 and ABV <= 8.00:
print ('Your beer has an alcohol content of ' + str(ABV) +'. Drink in moderation, you have a medium alcohol beer.')
print ('Your beer has an alcohol content of ' + str(ABV) +'. Be careful, you have yourself a bomb!')
Ok! Internet is misson critical and TV sucks.
I moved during November and lost my Internet for about a month. I did have Internet at work, but needless to say it didn’t feel right to work on my personal stuff at work…but wow was I impressed with how much we rely on the Internet! Some of the things that really caught me off guard:
- Had to have my wife pay my bills remotely, she turned into my virtual private assistant (straight from the 4 hour work week – thanks Ferris). Except I could understand her and was fully audited on all my transactions…
- Could only check my emails on my clunky 3G phone. Blah.
- Getting home at night and watching junk on TV is WAY worse that surfing on the web, even if your not surfing for anything in particular. At least you can read, watch videos, virtually socialize, man TV is such a dud. SUCH A DUD.
- Not being able to work at night stinks. When else can you catch up on all those ignored emails? During the day in the middle of meetings? Don’t think so.
- Missed out on Cyber Monday, dang.
- Couldn’t write in this blog, aggh!
- Couldn’t conference with family and co-workers in other time zones
And the list goes on.
Maybe Santa Clause can bring my a redundant fiber link and perma Internet connection LTE chip embedded in my nose.
A few weeks ago I published an article in Spanish about how much revenue large tech companies have in comparison to some of the countries around the world. To make a long story short, just two to three of the big tech companies put together have more revenue than the Gross Domestic Product (GDP) of many countries around the world. And with money comes power.
But how liquid are these companies, i.e. how much do they have in cash and other short term investments, i.e. current assets? As the old saying goes, cash is king, and boy do these tech juggernauts hold the crown. After a few minutes on Google Finance, Wikipedia and some other sites, I found some information, when compared to several governments, helps put things into perspective.
Cash and short term assets on some of the big tech companies balance sheets
- Microsoft has about 75 billion dollars in current assets. It’s not uncommon for them to add between 1-4 billion dollars in cash per quarter.
- Apple has about 47 billion dollars in current assets. They are also generating cash on a quarterly basis at an insane level.
- IBM also has about 47 billion in current assets. Do they generate cash every quarter? Just about, say a billion here, a billion there.
- Google is no slouch either and is in good company, they hold about 47 billion in current assets as well. They hold about 39 billion dollars in cash and short term investments.
- HP surprised me. Even with all their troubles of late they “only” have about 56 billion dollars in current assets.
- Cisco is also insane. They have about 57 billion in current assets.
- Let’s add EMC2 into the mix as well. They have about 10.2 billion dollars in current assets. Their operating cash flow is also solid.
- Dell…. about 30 billion in current assets. Not bad huh?
Cash balances for some governments
There’s an old saying out there: really good management is only necessary if you need to cover up for faulty product. Not like everything takes care of itself by just having a great product, but it certainly makes things a lot easier, doesn’t it?
A Little History
After several underpreforming quarters, the board brought co-founder Yang back in to try to get the company back to its roots. For the most part it worked, Microsoft bid 33 bucks a share for Yahoo!, but Yang and the board got greedy and rejected the offer. Then Silicon Valley veteran Bartz was brought in to shape the ship…that didn’t work so well either and investors acted. How would you like to be fired over the phone?
Bartz’s recent ouster from Yahoo! is no surprise, considering the company has been underperforming the S&P 500 for some time now. I mean, really, you could put any CEO into that position and anyone could flounder, unless their product and strategy were to change drastically. Issue is, they lost track of their core business.
Yahoo!’s Roots Are No Longer Applicable
I go to Yahoo!’s site once in a while, but it’s stale. News items are from Thompson Reuters or from the Associated Press. They also have a Travel site. Have you ever bought a plane ticket from Yahoo!? I bet you haven’t, you probably use Expedia, Priceline, Orbitz or go directly to your favorite airline’s website. By the way, Yahoo!’s site is very handy for testing your Internet connection: just type “ping http://www.yahoo.com”; and the site responds, one of the few to do so.
What’s the first thing we think about when when we think of Yahoo!? We think Internet portal and content, a.k.a. Internet mag, but I bet you don’t think of it as a premier search engine, heck that’s an afterthought as it’s not even their technology anymore. “I’m going to Bing for my favorite Yoga studio through Yahoo!”…no way. I also bet you don’t think of it as an B2B auction site, such as Alibaba, even though Yahoo! has a significant stake in the company.
When Yang started Yahoo! back in the 90′s he set it up to categorize information that was on the Internet so that he could find it better. So at its core, Yahoo! was and still attempts to be a portal that categorizes information so that you can find it. Trouble is the site is so full of content now that it’s more like a news magazine that a site to manage content via categories. Just type http://www.yahoo.com into your favorite web browser and you’ll see what I mean. Then Google came along and we all know how that went. Searching for content by first placing it into categories is cumbersome and no longer applicable!
If I were CEO of Yahoo! I would…hide under my desk. Anyone that has to take over the CEO has a huge challenge in front of them. Basically, there would be two choices: sell the company in pieces or shift their strategy. The former would be more appealing to the likes of Proxy-Battle-Guru Icahn, the latter would be more appealing to long term strategic investors. In any case, here are some ideas:
- Start selling applications in the Cloud: they could either penetrate this space via acquisition or could build their own technology by leveraging data centers. Google does it, Microsoft does it, heck all companies are doing it one way or another. They could sell applications specialized in SMB’s, such as something similar to Google Docs.
- Sell infrastructure to provide content on an automated basis: similar to the way Amazon sells its fulfillment services to third parties, Yahoo! could sell content publishing infrastructure to those who need it. I bet they have some significant IP to offer, not a lot of companies offer so much content at an aggregate level.
- Categorize Internet content by rank: SEO companies help position websites organically within Google results, but these are specific strategies to improve the relevancy of a website based on certain key words. However, it would be nice if Yahoo! could leverage all their categories and place “Top 10 Autoparts Websites” using their ranking algorithms.
What else could they do? Next few years shall be very interesting for Yahoo! Time to die a slow death or re invent themselves!