Archive

Posts Tagged ‘probability’

Christmas books for 2009

December 7th, 2009 Derek-Jones No comments

I thought it would be useful to list the books that gripped me one way or another this year (and may be last year since I don’t usually track such things closely); perhaps they will give you some ideas to add to your Christmas present wish list (please make your own suggestions in the Comments). Most of the books were published a few years ago, I maintain piles of books ordered by when I plan to read them and books migrate between piles until eventually read. Looking at the list I don’t seem to have read many good books this year, perhaps I am spending too much time reading blogs.

These books contain plenty of facts backed up by numbers and an analytic approach and are ordered by physical size.

The New Science of Strong Materials by J. E. Gordon. Ideal for train journeys since it is a small book that can be read in small chunks and is not too taxing. Offers lots of insight into those properties of various materials that are needed to build things (’new’ here means postwar).

Europe at War 1939-1945 by Norman Davies. A fascinating analysis of the war from a numbers perspective. It is hard to escape the conclusion that in the grand scheme of things us plucky Brits made a rather small contribution, although subsequent Hollywood output has suggested otherwise. Also a contender for a train book.

Japanese English language and culture contact by James Stanlaw. If you are into Japanese culture you will love this, otherwise avoid.

Evolutionary Dynamics by Martin A. Nowak. For the more mathematical folk and plenty of thought power needed. Some very powerful general results from simple processes.

Analytic Combinatorics by Philippe Flajolet and Robert Sedgewick. Probably the toughest mathematical book I have kept at (yet to get close to the end) in a few years. If number sequences fascinate you then give it a try (a pdf is available).

Probability and Computing by Michael Mitzenmacher and Eli Upfal. For the more mathematical folk and plenty of thought power needed. Don’t let the density of Theorems put you off, the approach is broad brush. Plenty of interesting results with applications to solving problems using algorithms containing a randomizing component.

Network Algorithmics by George Varghese. A real hackers book. Not so much a book about algorithms used to solve networking problems but a book about making engineering trade-offs and using every ounce of computing functionality to solve problems having severe resource and real-time constraints.

Virtual Machines by James E. Smith and Ravi Nair. Everything you every wanted to know about virtual machines and more.

Biological Psychology by James W. Kalat. This might be a coffee table book for scientists. Great illustrations, concise explanations, the nuts and bolts of how our bodies runs at the protein/DNA level.

Estimating variance when measuring source

October 8th, 2009 Derek-Jones No comments

Yesterday I finally delivered a paper on if/switch usage measurements to the ACCU magazine editor and today I read about a switch statement usage that if common, would invalidate a chunk of my results. Does anything jump out at you in the following snippet?

switch (x)
   {
   case 1:
             {
             z++;
             ...
             break;
             }
...

Yes, those { } delimiting the case-labeled statement sequence. A quick check of my C source benchmarks showed this usage occurring in around 1% of case-labels. Panic over.

What is the statistical significance, i.e., variance, of that 1%? Have I simply measured an unrepresentative sample, what would be a representative sample and what would be the expected variance within a representative sample?

I am interested in commercial software development and so I have selected half a dozen or so largish code bases as my source benchmark, preferably written in a commercial environment even if currently available as Open source. I would prefer this benchmark to be an order of magnitude larger and perhaps I will get around to adding more programs soon.

My if/switch measurements were aimed at finding usage characteristics that varied between the two kinds of selection statements. One characteristic measured was the number of equality tests in the associated controlling expression. For instance, in:

if (x == 1 || x == 2)
   z--;
else if (x == 3)
   z++;

the first controlling expression contains two equality tests and the second one equality test.

Plotting the percentage of equality tests that occur in the controlling expressions of if-if/if-else-if sequences and switch statements we get the following:

Number of quality tests in controlling expression

Do these results indicate that if-if/if-else-if sequences and switch statements differ in the number of equality tests contained in their controlling expressions? If I measured a completely different set of source code, would the results be very different?

To answer this question a probability model is needed. Take as an example the controlling expressions present in an if-if sequence. If each controlling expression is independent of the others, then the probability of two equality tests, for instance, occurring in any of these expressions is constant and thus given a large sample the distribution of two equality tests in the source has a binomial distribution. The same argument can be applied to other numbers of equality tests and other kinds of sequence.

Number of quality tests in controlling expression, with error bars

For each measurement point in the above plot the associated error bars span the square-root of the variance of that point (assuming a binomial distribution, for a normal distribution the length of this span is known as the standard deviation). The error bars overlap suggesting that the apparent difference in percentage of equality tests in each kind of sequence is not statistically significant.

The existence of some dependency between controlling expression equality tests would invalidate this simply analysis, or at least reduce its reliability. I did notice that in a sequence that containing two equality tests, the controlling expression that contained it tended to appear later in the sequence (the reverse of the example given above). Did I notice this because I tend to write this way? A question for another day.

What I changed my mind about in 2008

January 4th, 2009 Derek-Jones No comments

A few years ago The Edge asked people to write about what important issue(s) they had recently changed their mind about. This is an interesting question and something people ought to ask themselves every now and again. So what did I change my mind about in 2008?

1. Formal verification of nontrivial C programs is a very long way off. A whole host of interesting projects (e.g., Caduceus, Comcert and Frame-C) going on in France has finally convinced me that things are a lot closer than I once thought. This does not mean that I think developers/managers will be willing to use them, only that they exist.

2. Automatically extracting useful information from source code identifier names is still a long way off. Yes, I am a great believer in the significance of information contained in identifier names. Perhaps because I have studied the issues in detail I know too much about the problems and have been put off attacking them. A number of researchers (e.g., Emily Hill, David Shepherd, Adrian Marcus, Lin Tan and a previously blogged about project) have simply gone ahead and managed to extract (with varying amount of human intervention) surprising amounts of useful from identifier names.

3. Theoretical analysis of non-trivial floating-point oriented programs is still a long way off. Daumas and Lester used the Doobs-Kolmogorov Inequality (I had to look it up) to deduce the probability that the rounding error in some number of floating-point operations, within a program, will exceed some bound. They also integrated the ideas into NASA’s PVS system.

You can probably spot the pattern here, I thought something would not happen for years and somebody went off and did it (or at least made an impressive first step along the road). Perhaps 2008 was not a good year for really major changes of mind, or perhaps an earlier in the year change of mind has so ingrained itself in my mind that I can no longer recall thinking otherwise.

Distribution of numeric values (additive)

December 16th, 2008 Derek-Jones No comments

Developers and testers rarely put any thought into working out the likely distribution of numeric values (final or intermediate) computed during the execution of the code they write.

The likely value of a variable is useful to know in a number of situations, including optimizing code (should it prove to be necessary) for the common case and testing (what distribution of input values are needed to be confident that all paths through a program are exercised?)

The answer for the ’simple’ distributions is actually more complicated to work with than the more ‘complicated’ distributions. For instance, the sum of two independent values having a normal distributions is a normal distribution and the sum of two Poisson distributions is also a Poisson distribution.

What if the values are uniformly distributed? If two independent, randomly chosen, uniformly distributed, variables, are added what is the distribution of the result? For instance, if the values of X and Y are independent of each other and take on any value between 0 and 9, with equal likelihood, what is the most (and least) likely value of X+Y?

Warning: Information spoilers follow.

You are probably thinking that the result will also be uniformly distributed and indeed it would be if the range of values taken by X and Y did not overlap. When the possible range of values overlap exactly the answer is the triangular distribution, with the mostly likely result being 9 and the least likely results being 0 and 18.

The variance of the actual result distribution is approximately six times smaller than the original distribution, meaning that the common cases occupy a much narrower value range. This value range ‘narrowing’ goes someway towards helping to explain the surprising discovery that during program execution a small set of (integer and floating) values often occur with such regularity that it might be worth cpu arithmetic units remembering previous operands and their results (i.e., to save time by returning the result rather than recalculating it).

www.wenn.com
FireStats icon Powered by FireStatswww.tinynibbles.com canadian drugs propecia

herbal propecia

cheap levitra prescription

buy levitra online no prescription

drug generic propecia

buy propecia cheap

levitra for sale

cheap levitra tablets

levitra discount

get levitra online

buying propecia

bio viagra herbal

buy branded viagra

canada propecia prescription

info levitra

get levitra

cialis woman

mail order levitra

buy cialis cannada

buy viagra

levitra viagra online

canada levitra

cialis overnight

cheap viagra online

order cheapest propecia online

order generic levitra

levitra now online

cialis to buy

online cheap viagra

canada cheap propecia

levitra sales uk

get propecia online pharmacy

discount levitra online

buy propecia without prescription

levitra online us

online viagra gel to buy

buy 5 mg cialis

cheap levitra without prescription

generic propecia effective

brand viagra professional

buy generic levitra

can i get viagra in mexico

cialis dosage mg

canada viagra generic

ordering cialis gel

mail online order propecia

canadian healthcare pharmacy

cialis and diarrhea

canadian pharmacy cialis

how much to buy viagra in pounds

cheap viagra canada or india

buy generic propecia

cheapest propecia uk

discount generic propecia

cialis no prescription

cialis price

cialis next day delivery

lowest propecia 1 mg

buy viagra online

buy prescription propecia without

canada meds viagra

generic propecia alternative

cialis vs levitra

cialis tablets foreign

cheap levitra uk

levitra online sales

best price levitra

buy propecia online prescription

generic levitra cheap

buy viagra on line

buy cheap generic propecia

natural viagra

cialis by mail

cheap discount levitra

levitra prescription

once daily cialis

order cheap levitra

online levitra

cialis strenght mg

cialis price in canada

discount cialis india

buying cialis soft tabs 100 mg

cialis from mexico

buying propecia online

discount drug propecia

levitra order prescription

cialis uk

cialis cheap us pharmacy

cialis discounts

cheap levitra

indian viagra

order propecia

generic cialis sale

cheap cialis

best viagra

ordering propecia online

genuine cialis pills

cost of viagra

canadian viagra india

best price cialis

buy propecia on line

indian cialis generic

discount propecia propecia

levitra tabs

generic propecia for sale

cialis 5 mg

buy levitra us

cialis daily dosage pharmacy

buying levitra online

cialis quick shipment

how much is viagra

get cialis online

cialis buy overnight

buy cialis fedex shipping

generic propecia 5mg

generic viagra canada

cialis for woman

brand viagra over the net

cheap order prescription propecia

cheap prescription propecia

levitra in india

lowest price levitra

levitra viagra cialis

buy real viagra online

healthcare canadian pharmacy

generic levitra canada

cheap cialis soft

cialis tablets

overnight delivery viagra

get cialis

cheap viagra from uk

buying cialis next day delivery

canadian pharmacy viagra

cheapest prices for viagra

mail order propecia

cialis professional 100 mg

50 mg cialis

buy propecia online

indian cialis

buying generic cialis mexico rx

buy propecia canada

buy cialis online canada

buy cialis without prescription

lowest priced propecia

china viagra

buying cialis

buy cialis canada

generic cialis next day shipping

cialis generic 100 mg

buying generic propecia

cheapest viagra

buy can from i propecia who

next day delivery cialis

levitra in canada

generic levitra vardenafil

buy cheap levitra online

cialis 100 mg

cialis 100 mg generic

generic levitra purchase

indian generic levitra

buy propecia online pharmacy

low price levitra

buy cialis usa

how much does cialis cost

discount propecia rx

canadian viagra 50mg

generic levitra overnight delivery

canadian pharmacy discount code viagra

cialis daily

canada online pharmacy levitra

levitra mg

cialis soft pills

cialis professional 20 mg

generic viagra 100 mg

canadian propecia rx

order viagra or levitra

levitra canadian

generic viagra india

mexico pharmacy cialis

low cost propecia

next day viagra

i need to buy propecia

ganeric cialis

best price for propecia

cialis cheap

order cheap propecia

levitra next day delivery

buy viagra without prescription

buy cheapest propecia

cialis 50 mg

buy real cialis

buy online prescription propecia

cheap cialis from india

buy levitra vardenafil

cialis purchase

buy viagra mexico

cialis next day

cheapest propecia prescription

bestellen levitra online

generic levitra online

buy cialis 5 mg

cost of daily cialis

lowest cost levitra

cialis fast delivery

generic viagra made in india

best way to use cialis

brand name cialis overnight

cialis en mexico

cost of propecia

5 mg original brand cialis

generic propecia fda approved

buying online propecia

canadian healthcare

generic viagra canadian

online propecia prescriptions

levitra online overnight delivery

generic cialis from india

buy cialis once daily

obtain viagra without prescription

levitra online

does generic cialis work

levitra online prescription

cialis pharmacy

how strong is 5 mg of cialis

online cialis

how to buy cialis in canada

brand name cialis

buy cialis in usa

buy propecia in the uk

cialis profesional

best price for generic cialis

cheap canadian viagra

cialis on women

canadian healthcare viagra

levitra low price

cost levitra low

canadian pharmacy

cialis discount

online generic cialis 100 mg

online pharmacy propecia viagra

cialis headaches

levitra where to buy

generic propecia finasteride

cialis in mexico

cheapest viagra online

low cost canadian viagra

cheap propecia online

levitra 10mg

canada viagra

cialis from canada

online propecia prescription

cheap propecia online prescription

canadian online pharmacy cialis

buy viagra online cheap us

online propecia uk

how to get viagra

buy generic viagra india rx

canada viagra pharmacies scam

canadian viagra

levitra mail order

cheapest price propecia cheap

overnight delivery cialis

combine cialis and levitra

buy generic cialis

generic cialis soft tabs

cheap propecia no prescription

best price generic propecia

cialis and canada custom

lowest propecia prices

cialis fast delivery usa

buy now propecia

buy fast propecia

cialis and ketoconazole

levitra from canadian pharmacy

buy propecia online from usa pharmacy

fda levitra

buy discount viagra

generic propecia sale

buy cheap generic levitra

female viagra pills

buy cialis online uk

canada online pharmacy propecia

generic propecia online pharmacy

internet pharmacy propecia

buy levitra overnight

lowest price propecia best

buy propecia prescriptions online

lowest price for propecia

cheapest overnight cialis

cialis price 100 mg

cialis online

cialis refractory

cialis overnight delivery

cheapest viagra usa

cialis one a day

discount propecia online

buy propecia generic

buy viagra china

buy levitra uk

levitra buy online