Saturday, April 27, 2013

Software Estimation

My entry on Probabilistic Programming got me to wondering about estimating productivity. Made me dig out J.P. Lewis classic paper Mathematical Limits to Software Estimation.

Abstract: Algorithmic (KCS) complexity results can be interpreted as indicating some limits to software estimation. While these limits are abstract they nevertheless contradict enthusiastic claims occasionally made by commercial software estimation advocates. Specifically, if it is accepted that algorithmic complexity is an appropriate definition of the complexity of a programming project,then claims of purely objective estimation of project complexity, development time, and programmer productivity are necessarily incorrect.

Mr. Lewis wrote a lengthy supplement, elaborating on the many misunderstands of what the paper actually said. Alas it did not really help me figure how to estimate the time it might take to use probabilistic methods. At this point, that is probably not even possible given this prenatal state of the probabilistic methodology?


Probabilistic Programming

The Defense Advanced Research Projects Agency's (DARPA) budget proposals are always an interesting read. They lead to things like this, potentially Open Source Project: Probabilistic Programming for Advancing Machine Learning (PPAML); Solicitation Number: DARPA-BAA-13-31

Machine learning is at the heart of modern approaches to artificial intelligence. The field posits that teaching computers how to learn can be significantly more effective than programming them explicitly. This idea has revolutionized what computers can do in a wide range of domains, including Intelligence, Surveillance, and Reconnaissance (ISR), Natural Language Processing (NLP), Predictive Analytics, Cyber, and various scientific disciplines. Example applications include self-driving cars, image search and activity detection, object tracking, topic models, spam filters, recommender systems, predictive databases, and gene sequencing. Unfortunately, building effective machine learning applications currently requires Herculean efforts on the part of highly trained experts in machine learning. Probabilistic Programming is a new programming paradigm for managing uncertain information. The goal of the Probabilistic Programming for Advancing Machine Learning (PPAML) program is to facilitate the construction of machine learning applications by using probabilistic programming to: (1) dramatically increase the number of people who can successfully build machine learning applications; (2) make machine learning experts radically more effective; and (3) enable new applications that are inconceivable today.

Machine learning applications work by building a model of a phenomenon of interest and then training or conditioning that model with observed data, similar to the way we may 'teach' a Neural Network today. What Probabilistic Programming is not is the classic Inference Engine, rather it is a front end to classic IEs or yet unthought of IEs. BUGS would be an example of a classic IE. The Probabilistic Programming approach separates the model from the solver, making it possible for one set of users to develop the model without having to implement or know the details of the solver. With Probabilistic Programming languages, once they exist, developers will be able to focus on developing their models while solver experts will be able to embed their expertise in reusable new style inference engines.

Where I see Probabilistic Programming being of the most use in Embedded Space is in the area of network routing for the Internet of Things (leaving aside the issues of lack of conventional radio spectrum and the raising Internet noise floor slowing everything down for the moment).

There are some Software Safety issues to address, such as how is a Probabilistic Programming verified and validated? No human may actually know how it works, to explain how a particular conclusion was reached. MISRA well known for their C and C++ safety Guidelines does have an obscure section on Autocode generation. However that is still based on conventional technology of today. What happens when true Artificial Intelligence systems do start creating programs that we rely on?

To keep up to date follow the Probabilistic-Programming.org Mailing List.


Monday, April 1, 2013

Weight of the Soul or Dust on the Scale?

Back around Halloween I mentioned my visit to the J. B. Rhine Research Center (Rhine was the first to do experiments with 'ESP' at Duke University in Durham, North Carolina in the 1920's), see Near Death at the Rhine Research Center. The first formal report of the optical work, Electromagnetic Emission From Humans During Focused Intent by William T. Joines, Stephen B. Baumann (deceased), and John G. Kruth, see Journal of Parapsychology 76(2), is now online (Membership is required). The formal report does cover Mitogenetic Radiation something I thought was lacking previously.

What also fascinates me is that if they can get the funding for this future research project: They want to try to weigh people that claim they can leave their body, sometimes refereed to as Astral Travel or Astral Projection (the original experiments invovled death, no one wants to be killing the research subjects today) , and see if there is a change in their weight.

If you believe in such things that is your personal choice, what is fascinating to me after looking into this a bit is just how hard it is to make an precise and accurate weight scale. This scale road has been traveled in the past:

[Jim Williams] worked for a few years with the Nutrition and Food Sciences Dept at MIT, building equipment for them. Once he built a scale that was so sensitive he could stand on it, take a bite out of a donut and measure the weight of the bite. He had to add a low frequency notch filter to take out the heartbeat of the user as the blood flowed up and down the femur arteries, modulating the weight on the scale. - I Remember Jim Williams, a Guru of the Analog Electronics World, as Much an Artist as Engineer.

Scott Wayne, Analog Dialogue's editor, pointed me to Jim Williams scale paper, Thank You Scott: High resolution scale: Measures up to 250 lb +/- .01 lb, detects a single bite of food, Analog Dialogue, vol. 10, no. 2, p. 17, 1976. Every issue of Analog Dialogue, from Volume 1, Number 1, 1967 through the present is available in Analog Devices' Analog Dialogue's archives.

Getting back to our current time, Vishay Precision Group (VPG) has released a Video, described here, on their Z-Foil Resistors.

In the video, a custom designed scale is used to weigh 200 grams of gold at +25C and +60C, first utilizing thin film technology for the gain resistors and then using the Z-foil resistors.

At +25C, both the thin film and Z-foil resistors measure the 200 grams of gold for a value of $11,400. With an ambient temperature increase to +60C, however, the assembly utilizing precision thin film resistors weighs the gold as 197.8 grams for a value of $11,277 - which represents a 'loss' of $123. The same assembly using Z-foil resistors is not affected by the temperature change, providing an accurate measurement of 200 grams at +60C - and no loss in measured value.

See also Why Honest Weigh Scales Are Application Specific and Application Note 5275: Calibration - Needless or a Necessity?, from Maxim Integrated.

In 1976 we could measure +/- 0.16 of ounce change in a 250 pound person. Thirty-seven years on, I wonder if Analog Devices, Intersil (see the video), Linear Technology (Jim Williams), Maxim Integrated or Vishay Precision Group (VPG), would step up to the challenge of funding the Rhine's project to showcase their current technologies, on how things have improved? Maybe you think you are up to the challenge of this scale design? Let us know.


'Magic Smoke' Resistors available off-the-shelf

Anyone that has been around electronic devices for any length of time know that when the devices fail, they tend to go up in smoke, leading to the idea that electronic parts are run by Magic Smoke. Alas our sterilized, sanitized, paranoid society is taking the *fun* out of such things as hands on learning.

While places like Analog Devices' Engineering University are great for learning theory and hands on labs with their hardware, sometimes it is far more educational, and down right *fun*, to learn why things went wrong. Only experience is going to teach one, the important debugging skill, of the differences in smells between burning resistors, burning capacitors, and burning circuit board material. Also teaches the importance of wearing protective eyewear (never know when a backwards part might try to impale itself into the ceiling or ones face if it is closer), and having a electrical rated fire extinguisher next to the workbench.


What brings us to Magic Smoke, is that Vishay has upgraded their old line of Electro-Pyrotechnic Initiator Chip Resistor (EPIC) (and Design Guide and App Notes) to the new Massive Electro-Pyrotechnic Initiator Chip Resistor (MEPIC).
MEPIC resistors, also known as bridge resistors, are resistive elements that convert electrical energy into heat energy in a precise electro-thermal profile for the purpose of initiating a series of pyrotechnic events in a controlled energetic reaction. [They go *BOOM* on command, which is different than Rapid Spontanious Self-Disassembly.]
The new Vishay Sfernice resistor is optimized for electronic igniter applications in automotive safety systems for the deployment of airbags and other safety devices; digital blasting in mining applications; and in fireworks applications for better synchronization of fireworks, music, and special effects.
With firing energy down to 1.5 mJ and a typical ohmic range of 2 Ohms (+/- 10 %), the device provides designers with very predictable, reproducible, and reliable behavior.
Offered in the standard 0805 case size for the wraparound and flip chip versions, with other sizes available upon request, the resistor features easy set-up of firing levels, and is compatible with various pyrotechnic compositions.
Offering ESD withstanding to 25 kV without extra protection, the MEPIC resistor's performance meets no fire/all fire conditions and the requirements of USCAR, AKLV16, and major car manufacturer standards. The device is RoHS-compliant and conforms to Vishay "Green" standards. [Is it not great that Fuzes are 'Green'?]
Almost lost in the mists of time is that in the past manufactures made military specific parts, before someone thought that Commercial Off The Shelf technology (COTS) was a good idea (it wasn't). National Semiconductor's, now part of TI, Application Note #761:Electronic Fuzing covers the basic terminology of Fuzing:
Fuzing mechanisms are devices used to "safe", "arm" and detonate explosive military munitions (such as missiles, mines, demolition charges, explosive shells ranging in size from 20 mm to 16 inches, unguided bombs and various submunitions). Early electronic fuzes developed for 5-inch naval air defense...
Sadly even tho I'm it good standing with my Vishay Rep. Firm, samples of (M)EPIC parts are restricted to people that can show good cause for getting them, so Homeland Security can relax. To bad, think of the fun the people at Hack A Day or Make Magazine could have with some these...as well as those great educational experiences that are being lost...

Picture of Aliens and UFO's found on military web site.

Picture of Aliens and UFO's found on military web site.






Sunday, March 24, 2013

How many are taking the Software Engineering exam this April?

As regular readers are aware I've been chronicling events related to the new Software Engineering Exam, that some states are starting to offer as part of a Professional Engineer title.

I contacted the National Council of Examiners for Engineering and Surveying (NCEES) and asked them how many people had signed up for the new test, to be given for the first time this coming April. Sadly I was told that information was confidential. Answers like that always invoke thoughts of conspiracy theories in my mind, as to what is being hidden? More than likely it is simply a mater of confidentiality. The data probably could be gotten from each states licensing board if you were motivated enough to ask, I'm not right now.

I did pick up a couple of other tidbits of information. The new Software Engineering exam is considered a Group-2 exam, meaning that it has very small numbers of takers each time it is given. Hence this exam is only given once a year. Group-2 exams are required to have a sponsoring society, which for this exam is the IEEE. Do you think interest in this exam will increase with time (Without government mandates)?

The Electrical and Computer Exam, that has been around since 2009, is a Group-1 exam meaning that it is one of the larger exams that has been given frequently, as such requires no sponsor.

There has been concern that so few schools have the required accreditation for taking the Software Engineering exam. As each state board must approve a candidate before they are allowed to take the exam. They are the final decision maker on who is eligible and who is not.

At this point now we wait. We are waiting for the next software disaster that kills people due to our collectively buggy software rushed out the door to meet trade show deadlines and market pressures, rather than properly engineering the software in the first place. That will lead to the draconian government regulations. The framework for the regulations are now in place. As an industry are we going to clean up our act now or complain greatly when it is to late, when regulations are forced upon us?

By the way, what do you tell the Middle School Student that asks "Um, I'm in middle school... Are jobs actually like this?". I've given my answer in the past.

Software Engineering, License to write software, Firmware

Safer Embedded Software

Something new I'm trying here in the blog is to open it up to an occasional Guest Blogger. If you have an idea for something that fits in with the general theme of the site, get in contact with me.

Today's Guest Blogger is Rajstennaj Barrabas, whom may be contacted at: RB (at) OkianWarrior (dot) com . If you have comments for RB use that address or leave comments below. I'll turn it over to RB now:

Examining past software failures gives us insight into how failures arise, so we can anticipate and avoid failures in the future.

One such failure is the Therac-25, a radiation therapy machine that killed several patients due to buggy software.

Very briefly, the Therac has a high-power mode which is used once a metal shield drops into place to protect the patient. A particular keyboard sequence entered by the operator (double-pressing the "return" key at just the right moment) caused a cascade of failures where the software eventually jumped into the middle of a function. The system engaged high-power mode without first lowering the shield, killing the patient.

To my mind, this was the first fatal accident caused by a software problem; or at least, the first well-known one. People suddenly realized that software could hurt people, and that perhaps special care should be taken.

(The link has a more detailed summary, with pointers to more in-depth reports.)

Analysis at the time noted that the high-power function did not check that the protective shield was in place. Lowering the shield was done prior to the call, and the function assumed that this had happened.

The conclusion was that software should always check its assumptions, and this became a set of "best practices" for safety-certified systems.

In safe software, every function should began with ASSERTs that check the arguments for validity, and these should be active in the released code. The execution time is negligible in most cases, and ASSERTs do a good job of ensuring proper behaviour.

As calculation proceeds, more ASSERTs should check the intermediate results; for example, to ensure nothing overflows, or that values are in range.

The Therac function could have ASSERTed that the shields were in place.

Most embedded programs don't use 100% of the CPU time. The spare capacity can be used to check up on the program and further ensure that everything is going well.

Each module can supply a function "xxxBIT" (where "BIT" stands for "Built In Test") which checks the module variables for consistency. As the program runs, it can call these functions during idle moments.

For example, the serial driver (SerialBIT) can check that the buffer pointers still point within the buffer, that the hardware registers haven't changed, and so on.

On bootup, the memory manager (MemoryBIT) knows the last-used static address for the program (ie - the end of .data), and should fill unused memory with a pattern. In it's spare time it checks to make sure the unused memory still has the pattern. This finds all sorts of "thrown pointer" errors. (Checking all of memory can take too long, so MemoryBIT can be coded to check a small portion each call.)

The stack pointer can be checked - put a pattern at the end of the stack, and if it changes you knew something went recursive or used too much stack (StackBIT).

The EPROM can be checksummed periodically.

Every module should have a BIT function which checks every imaginable error, to be called in the processor's spare time - over and over continuously.

The Therac could have continually tested its calculations to check for cascade failures.

The overall effect is a very "stiff" program - one that will either work completely or won't work at all. There is no intermediate behavior, no flexibility of action. Cascade failures are caught early, terminating the operation before things get out of hand.

A "stiff" program doesn't give erroneous or misleading results - it either works as intended or fails completely. Showing a blank screen is better than showing bad information, or even a frozen screen.

(Of course, this is situation specific. A blank screen is OK for aircraft - where the flight crew can take appropriate action - but perhaps not medical. You can still detect errors, log the problem, and alert the user.)

Some functions are time sensitive and can't afford the time spent error checking (interrupt handlers, for instance), but these can be identified and removed on a case-by-case basis.

Conventional wisdom says to use checking during development, and remove it on released code.

Done right, error checking has negligible impact on code speed but returns great gains in safety.


Sunday, March 17, 2013

Government raises your taxes with new CPI calculations

I have written in the past, Why is the cost of my Bill of Material (BOM) so much higher than last week? The Orwellian doublespeak answer: Quantitative Easing, about how the government is manipulating the money supply, and how it has real world effects on our designs. Dollar Stretcher Guest Blogger Rick Kahler has written about how the government is now inflating the money supply, as my past columns predicted they would, by manipulating how the Consumer Price Index (CPI) is calculated. They have manipulated this number many times in the past such as by adding in the Military Personnel, removing real world items like food, gas and fuel. So do check out Rick's The Ultimate Stealth Tax: Inflation. Also you can get real inflation numbers (1980 and 1990 based) from John Williams ShadowfStats.

"...The chained CPI is a tax increase for much the same reason. Many income tax brackets and deductions are indexed to inflation. Smaller annual adjustments to the brackets because of the lower CPI will push more people into higher tax brackets..."

1980 Based Inflation Chart

1990 Based Inflation Chart

One of the significant causes, of which there were many, of the Great Depression was when the Federal Reserve contracted the money supply. Even Warren Buffett has stated that he is concerned what will happen once the Federal Reserve Bank starts selling its holdings. Interestingly Governor Ben S. Bernanke has commented on this in the past: Money, Gold, and the Great Depression -- Remarks by Governor Ben S. Bernanke, At the H. Parker Willis Lecture in Economic Policy, Washington and Lee University, Lexington, Virginia, March 2,2004.

Many are saying that we should return to the Gold Standard. That is each 'dollar' is exchangeable for real tangible gold, in theory. Places like the World Gold Council are, of course, all for this. Many banks are already starting to dump US Dollars to stock up on Gold. Hence the same people that are creating the mess we are about to face will be the same people controlling the Gold. Do you see this as an improvement? I do not.

"Central banks have begun to reduce reserve portfolio allocations to US dollars and euros in favor of alternative reserve assets. A portfolio optimization analysis concludes that gold, with its lack of credit risk and deep and liquid market, is one of the most attractive alternatives in this diversification process. Accordingly, building gold reserves in tandem with new alternatives is an optimal strategy as these markets need time to develop and allocations to gold remain largely below optimal levels." -- Central bank diversification strategies: Rebalancing from the dollar and euro. [Registration is required to download the report.]

My past ramblings on the issue of 'Money' and Inflation:

Even the main stream press is catching up to what I was talking about in 2010:

The Treasury sells bounds, sheets of paper with no intrinsic value, to the Federal Reserve for things that politicians do not have the honesty to come out and say directly that they need to raise our taxes to support. The Fed buys these bonds with 'money' that it created from nothing. This created 'money' is put into circulation, making your money worth less each time it happens. This inflation is the most insidious hidden tax that you and I pay. Few figure this system out because it is usually hidden behind the Orwellian doublespeak of economics such as Quantitative Easing.

Will you be ready for the Greater Depression?