Appendix B: Introduction to Microsoft Office Excel Microsoft Office Excel is a spreadsheet program to store and analyze information. We recommend its use due to the fact that it is widely available and has powerful mathematical, statistical and graphical capabilities, with which all the numerical examples in this book can be carried out. In this appendix, we outline main functions and applications of Excel. The outline of the appendix is as follows. Section B.1 presents the functions of Excel and Section B.2 introduces Solver of Excel. We discuss simulation for reliability analysis using Excel in Section B.3. Other relevant issues are briefly outlined in Section B.4. B.1 Built-in functions of Excel Excel functions include the following categories: Database functions Date and time functions Engineering functions Financial functions Information functions Logical functions. They are “false”, “true”, “and”, “or”, “if”, and “not”. Lookup and reference functions Math and trigonometry functions Statistical functions Text functions, and External functions. Some important math functions are shown in Table B.1; some common statistical functions are shown in Table B.2; and some important distribution functions are shown in Table B.3. More details can be found from the user’s manuals of Excel or using Excel’s “help”. Table B.1 Math functions Function Description abs(x) Return the absolute value of x ceiling(x) Round x to the nearest integer combin(n, k) Return the number of combinations choosing k items from n items. gammaln(x) Return the natural logarithm of ( x ) exp(gammaln(x)) Return ( x ) exp(x) Return the value of the exponential function at x fact(x) Return the value of x! floor(x) Round x down, toward zero int(x) Round x down to a nearest integer ln(x) Return the natural logarithm of x pi() Return the value of product Multiply its arguments rand() Return a pseudo random number between 0 and 1 round(x, j) Round x to a number with j digits sign(x) Return 1, -1 or 0 if x > 0, < 0 or = 0 sum Add its arguments trunc(x, j) Truncate x to a number with j digits Table B.2 Statistical functions Function Description average(a, …, b) Return the average of (a, …, b) correl(A, B) Return the correlation coefficient between datasets A and B count Return the number of nonblank cells in a range kurt(a, …, b) Return the kurtosis of (a, …, b) large(A, k) Return the k-th largest value in the dataset A max(a, …, b) Return the maximum value of (a, …, b) median(a, …, b) Return the median of (a, …, b) min(a, …, b) Return the minimum value of (a, …, b) rank Return the rank of a number in a list of numbers skew(a, …, b) Return the skewness of (a, …, b) small(A, k) Return the k-th smallest value in the data set A stdev(a, …, b) Estimate standard deviation of (a, …, b) var(a, …, b) Return the variance of (a, …, b) Table B.3 Distribution functions Function Description binomdist(x, n, p, true [false]) Return the cdf [pmf] at x gammadist(x, a, b, true [false]) Return the gamma cdf [pdf] at x with the mean parameter a and standard deviation parameter b. gammainv(p, a, b) Return the inverse of gamma cdf. lognormdist(x, a, b) Return the cdf of lognormal distribution with the mean parameter a and standard deviation parameter b Return the inverse of the lognormal loginv(p, a, b) distribution Return the pmf of negative binomial negbinomdist(x, n, p) distribution normdist(x, a, b, true [false]) Return the normal cdf [pdf] at x with the mean parameter a and standard deviation parameter b. norminv(p, a, b) Return the inverse of the normal cdf. poisson(x, a, true [false]) weibull(x, a, b, true [false]) Return the Poisson cdf [pmf] at x with the mean parameter a. Return the Weibull cdf [pdf] at x with the shape parameter a and scale parameter b. B.2 Solver of Excel “Solver” can be evoked to find the maximum or minimum of a function with a set of constraints, or to solve an equation. Excel will install the Solver by clicking Add-Ins on the Tools menu. Once the add-in is installed, one can run Solver by clicking Solver on the Tools menu. The user will need to input the required information in the Solver parameters dialog box. It consists of four parts: Target cell, which gives the value of a univariate or multivariate function Type of the objective, which includes “max”, “min” or “equal to a specified value” Variables cells, and Constraints (optional). Example B.1: Find the mode of the gamma density function with the shape parameter 5.6 and the scale parameter 9.3. Referring to Table B.4, the computational process is as follows: Key “Mode” into cell A1 and “Target” into cell A2. Key an initial value of the mode by guessing (say 50) into cell B1. Key “= gammadist(b1, 5.6, 9.3, false)” to cell B2. Evoke “Solver” from “Tools” of Excel. Fill “b2” to the target cell and select “Max” from the “Equal To” list. Fill “b1” to the space of “by changing cells”. Click “Solver” and then we will obtain the output shown in Table B.4. Namely, the mode is at tm 42.78 with f (tm ) 0.01964. Table B.4 Spreadsheet of seeking the mode of the gamma pdf Row \ column A B 1 Mode 42.78 2 Target 0.01964 B.3 Simulation for reliability analysis Monte Carlo simulation for reliability analysis relies on pseudo random numbers to generate random times to failure based on a given failure distribution F ( x) . A pseudo random number between 0 and 1, p , is generated by Excel function rand(). A random life x is given by x F 1 ( p) . For the Weibull distribution, x is given by x [ ln(1 p)]1/ [ ln( p ')]1/ where p ' is also a random number between 0 and 1. Example B.2: Assume that the time to failure follows the lognormal distribution with l 1.0 and l 0.5. Generate a failure point process, which is truncated at t 20 . Referring to Table B.5, the simulation process is as follows: Key “xi”, “ti” and “Ti” into cells A1, B1 and C1, respectively. Enter “=loginv(rand(), 1, 0.5)” to cell A2, and copy it to cells A3, A4, ….. Enter “=a2” to cell B2, type “=b2+a3” to cell B3 and copy this to cells B4, B5, …. Enter “=min(20, b2)” to cell C2 and copy this to cells C3, C4, …. The outputs are shown in Table B.5. It is noted that this simulation produces a censored observation x7 20 19.3688 0.6312 . When pressing the key F9, all values of failure times are updated and the outputs change. Table B.5 A failure point process obtained from simulation Row \ column A B C 1 xi ti Ti 2 1.14408 1.14408 1.144076 3 2.56609 3.71017 3.710171 4 3.03061 6.74078 6.740785 5 6.17781 12.9186 12.9186 6 4.56061 17.4792 17.47921 7 1.88963 19.3688 19.36884 8 3.91215 23.281 20 B.4 Others Excel has a number of other attractive functions such as “data analysis” tools, including regression. Microsoft Excel uses Visual Basic for Applications to create the macros for automating re-calculation, variation of parameters, and collection of results. The macros are particularly useful for solving relatively complex mathematical problems. Excel can accept data in real time through several programming interfaces, which allow it to communicate with many data sources. Finally, graphical capabilities of Excel allow displaying various function relations and creating various types of charts. Math and Trigonometry functions Function Description ABS Returns the absolute value of a number ACOS Returns the arccosine of a number ACOSH Returns the inverse hyperbolic cosine of a number ASIN Returns the arcsine of a number ASINH Returns the inverse hyperbolic sine of a number ATAN Returns the arctangent of a number ATAN2 Returns the arctangent from x- and y-coordinates ATANH Returns the inverse hyperbolic tangent of a number CEILING Rounds a number to the nearest integer or to the nearest multiple of significance COMBIN Returns the number of combinations for a given number of objects COS Returns the cosine of a number COSH Returns the hyperbolic cosine of a number DEGREES Converts radians to degrees EVEN Rounds a number up to the nearest even integer EXP Returns e raised to the power of a given number FACT Returns the factorial of a number FACTDOUBLE Returns the double factorial of a number FLOOR Rounds a number down, toward zero GCD Returns the greatest common divisor INT Rounds a number down to the nearest integer LCM Returns the least common multiple LN Returns the natural logarithm of a number LOG Returns the logarithm of a number to a specified base LOG10 Returns the base-10 logarithm of a number MDETERM Returns the matrix determinant of an array MINVERSE Returns the matrix inverse of an array MMULT Returns the matrix product of two arrays MOD Returns the remainder from division MROUND Returns a number rounded to the desired multiple MULTINOMIAL Returns the multinomial of a set of numbers ODD Rounds a number up to the nearest odd integer PI Returns the value of pi POWER Returns the result of a number raised to a power PRODUCT Multiplies its arguments QUOTIENT Returns the integer portion of a division RADIANS Converts degrees to radians RAND Returns a random number between 0 and 1 RANDBETWEEN Returns a random number between the numbers you specify ROMAN Converts an arabic numeral to roman, as text ROUND Rounds a number to a specified number of digits ROUNDDOWN Rounds a number down, toward zero ROUNDUP Rounds a number up, away from zero SERIESSUM Returns the sum of a power series based on the formula SIGN Returns the sign of a number SIN Returns the sine of the given angle SINH Returns the hyperbolic sine of a number SQRT Returns a positive square root SQRTPI Returns the square root of (number * pi) SUBTOTAL Returns a subtotal in a list or database SUM Adds its arguments SUMIF Adds the cells specified by a given criteria SUMPRODUCT Returns the sum of the products of corresponding array components SUMSQ Returns the sum of the squares of the arguments SUMX2MY2 Returns the sum of the difference of squares of corresponding values in two arrays SUMX2PY2 Returns the sum of the sum of squares of corresponding values in two arrays SUMXMY2 Returns the sum of squares of differences of corresponding values in two arrays TAN Returns the tangent of a number TANH Returns the hyperbolic tangent of a number TRUNC Truncates a number to an integer