Engineering for the real world

Review of Numbers '09 for engineers

When Apple first released iWork '08 I immediately reviewed Numbers. I love the way that Excel and other spreadsheets have changed the way that engineering calculations are carried out, but over the last 10 years very little has changed to the humble spreadsheet. Apple finally decided to change the spreadsheet application with Numbers, but when I reviewed it the first time, there were a few problems. I couldn't use iWork for all my spreadsheets because of problems with the plotting and a lack of easy scripting support. So for iWork '09 have my wishes been answered?

The first thing I tried as importing a two existing spreadsheets. The import is now, near perfect. The problems last time included custom cell formats disappearing, problems with the graphs and missing spreadsheet functions. Now the only errors that pop up when importing a spreadsheet are only relatively minor issues such as defining plot areas. On top of all this, Numbers now seems to run at a similar speed to Excel when running the larger spreadsheets used in engineering.

One of my biggest requests was better graphing. Good plotting of x against y data was not possible in the previous version of iWork. The latest version allows x and y data as well as labels to be referenced to spreadsheet cells. This totally changes the form that graphs can take and allows the user to create most of the key types of graph. Log scales can now also be use on both axes.
pastedGraphic

Both data series for graphs and formulas use a new format with coloured labels with attached drop down toolbars. These drop down menus don't add much functionality but they really do aid the reading of an equation more than the simple colouring currently used in Excel. ultimately I'd like to see an improvement to the way brackets are used in the formulae to make them even more readable, but this is another good incremental improvement.
New formulae

The other new feature included is the formula list. The formula list is a complete list of all the formulas in a spreadsheet including a cell reference, a result and details of the formula. The list also includes a comprehensive find and replace feature. I'm not sure that I will use this feature much, but occasionally it might be useful to run through a spreadsheet to check for odd formulas in a series. It might also prove to be a useful to to review how spreadsheets work, allowing a viewer to quickly look through the types of formulae being used. What might be more useful in the future is this view to take on another form where the spreadsheet is set out in a graphical or flow chart way so that a review can easily see the flow of information through the chart. I know this type of view would have helped me in the past where previously I only had Excels formula auditing feature to help.
Formula list

There are many new functions that have been added to the latest version of Numbers. Whilst many of the new functions are fairly specific and of limited use to the general user, the new statistical distributions will be useful to many engineers. Statistics seems to becoming more and more important to engineers as time goes by so the inclusion of a comprehensive range of distributions , including Beta distributions, Binomial distributions, Gamma distributions, Lognormal distributions, and T distributions, is a really useful feature.

The other key feature request I originally made was the inclusion of an Applescript dictionary. This would allow other features to be included in the spreadsheet, such as Monte-Carlo analysis. Brilliantly Apple have also done this. All iWork applications now have an Applescript dictionary which makes then scriptable. Analyses such as a Monte-Carlo analysis can now be undertaken using Numbers. Numbers really is now the only spreadsheet an engineer will typically need.

I can heartily recommend a trial of the new version of Numbers in iWork '09 if you use spreadsheets regularly in your working life.


Seeding random numbers

Statistical modelling is part of the standard engineers tool set. The desktop computer means running scenarios with multiple inputs an easy task for all engineers. Most of these tools use random numbers to generate varying outputs. The mechanics of generating random numbers is a mathematical art to itself, but there are some key features when using statistical methods that need to be understood for effective modelling.

One of these key features is the seed. Random numbers are generated using algorithms that take an input value and generate a sequence of numbers that are apparently random. The input value is called the seed. Most programmes use the time when the first random number is generated as the seed; this then ensures a different sequence is generated each time a programme is run.

Overriding the use of the time as the seed does however have a number of benefits:

It allows scenarios to be re-run, particularly important where scenarios are used to generate the design in a safety critical situation.

It allows scenarios to be partially re-run. By using the same input parameter the scenario can be started in the same way, but using the seed, the random number sequence can be effectively re-set. This then allows a bifurcation in the model with a different outcome part way through the model.

It gives repeatability to models, a key component of any analysis that is quality audited. If you are having your analysis checked and it doesn't have built in auditing features such as date stamped reports, your checker must be capable of recreating identical results to yours. The only way of doing this in a statistical model such as UDEC is to set the deed of the model prior to the runs so that the checker can recreate exactly the same model.

So with all that in mind, here are a few ways of setting random number seeds in your models:

Excel

With Excel the easiest way to generate random numbers with a seed is to use the Data Analysis tool pack. I usually find that when I'm working with Excel and random numbers I'm having to use visual basic. For me setting the seed programmatically in Excel using Randomize statement.

Apple Numbers 1.0
Bad news here, I don't know how to set the seed in numbers. It doesn't really surprise me given the lack of scripting associated with Numbers. I remain hopeful of many improvements in the next version of Numbers and this is definitely one of them.

Cocoa
In Cocoa just use the srandom() function. There are plenty of examples out there with this in.

Applescript

In Applescript just set the seed when you first generate a random number using set firstRandom to random number from 1 to 100 with seed seedValue. I've been using this with no problems on an Application that I am currently writing in Applescript Studio. One thing to be aware of though is the some item of function. This doesn't seem to respond to seeding so well so other methods of taking a random value from a list using a directly generated random number seem to work better.