Problem

You're analyzing a dataset and would like to create a histogram plot of the data showing its frequency distribution.

Solution

Use Excel's `FREQUENCY` function to compute the frequency of occurrence of each data point and use Excel's charting features (see Chapter 4) to create the histogram plot. Or use the Histogram tool in the Data Analysis add-in to compute the frequencies of occurrence and then use Excel's plotting features.

Discussion

Figure 5-4 shows a histogram plot (bar graph) along with a frequency polygon (the thin line) and cumulative frequency plot (the bold line) for a set of data. The dataset for this example plot represents the angular response of a torsional spring.

You can quickly create this sort of chart using the techniques discussed throughout Chapter 4. You'll first have to compute the actual frequency distribution for your dataset, and to that end you have two choices in Excel: the `FREQUENCY` function or the Histogram tool included in the Data Analysis add-in.

Figure 5-5 shows a portion of a spreadsheet containing the data used for the histogram plot shown in Figure 5-4.

Figure 5-4. Histogram plot

The angular response data contained in column A is the original dataset for which frequencies are computed. Before applying the `FREQUENCY` function, you must set up a range of discrete bin values, called *bins*. The bins form bands, or ranges of values, within which values in the original dataset will be lumped when compiling frequencies of occurrence. In this example, I know the angular response values fall within approximately -15 to 15 degrees; therefore, I set up a range of bin values from -15 to 15 degrees in increments of 1 degree. These are contained in column C in Figure 5-5.

To compute the frequencies for each bin, I applied the `FREQUENCY` formula, passing the dataset cell range as the first parameter and the bin cell range as the second parameter. For example, the formula in cell D5 is `{=FREQUENCY($A$5:$A$1005,$C$5:$C$35)}`. Notice that this is an array formula and to enter it you must first select the entire output cell range, cells D5 to D35 in this case, and then enter the formula by pressing Ctrl-Shift-Enter.

Figure 5-5. Histogram example data

You can compute such a frequency distribution using the Histogram tool instead of the `FREQUENCY` function if you'd like. To do so, select Tools images/U2192.jpg border=0> Data Analysis from the main menu bar to open the Data Analysis dialog box shown in Figure 5-6.

Then select the Histogram tool from the list of available tools and press OK to open the Histogram dialog box shown in Figure 5-7.

Figure 5-6. Data Analysis dialog box

Figure 5-7. Histogram tool dialog box

In the Input Range field, enter or select from your spreadsheet the range of cells containing the input dataset. In the Bin Range field, enter or select the range of cells containing the bin values.

Under "Output options," select your preferred location for the output. In Figure 5-7, I set the output range to start at cell C39 in the same worksheet that contains the original dataset.

There are a few other options you can choose, and in this example I chose the Cumulative Percentage option to generate values for the cumulative plot shown earlier in Figure 5-4. Upon pressing OK, you should see results similar to those shown in Figure 5-5.

See Also

Check out Chapter 4 to learn more about creating charts in Excel.

Using Excel

- Introduction
- Navigating the Interface
- Entering Data
- Setting Cell Data Types
- Selecting More Than a Single Cell
- Entering Formulas
- Exploring the R1C1 Cell Reference Style
- Referring to More Than a Single Cell
- Understanding Operator Precedence
- Using Exponents in Formulas
- Exploring Functions
- Formatting Your Spreadsheets
- Defining Custom Format Styles
- Leveraging Copy, Cut, Paste, and Paste Special
- Using Cell Names (Like Programming Variables)
- Validating Data
- Taking Advantage of Macros
- Adding Comments and Equation Notes
- Getting Help

Getting Acquainted with Visual Basic for Applications

- Introduction
- Navigating the VBA Editor
- Writing Functions and Subroutines
- Working with Data Types
- Defining Variables
- Defining Constants
- Using Arrays
- Commenting Code
- Spanning Long Statements over Multiple Lines
- Using Conditional Statements
- Using Loops
- Debugging VBA Code
- Exploring VBAs Built-in Functions
- Exploring Excel Objects
- Creating Your Own Objects in VBA
- VBA Help

Collecting and Cleaning Up Data

- Introduction
- Importing Data from Text Files
- Importing Data from Delimited Text Files
- Importing Data Using Drag-and-Drop
- Importing Data from Access Databases
- Importing Data from Web Pages
- Parsing Data
- Removing Weird Characters from Imported Text
- Converting Units
- Sorting Data
- Filtering Data
- Looking Up Values in Tables
- Retrieving Data from XML Files

Charting

- Introduction
- Creating Simple Charts
- Exploring Chart Styles
- Formatting Charts
- Customizing Chart Axes
- Setting Log or Semilog Scales
- Using Multiple Axes
- Changing the Type of an Existing Chart
- Combining Chart Types
- Building 3D Surface Plots
- Preparing Contour Plots
- Annotating Charts
- Saving Custom Chart Types
- Copying Charts to Word
- Recipe 4-14. Displaying Error Bars

Statistical Analysis

- Introduction
- Computing Summary Statistics
- Plotting Frequency Distributions
- Calculating Confidence Intervals
- Correlating Data
- Ranking and Percentiles
- Performing Statistical Tests
- Conducting ANOVA
- Generating Random Numbers
- Sampling Data

Time Series Analysis

- Introduction
- Plotting Time Series Data
- Adding Trendlines
- Computing Moving Averages
- Smoothing Data Using Weighted Averages
- Centering Data
- Detrending a Time Series
- Estimating Seasonal Indices
- Deseasonalization of a Time Series
- Forecasting
- Applying Discrete Fourier Transforms

Mathematical Functions

- Introduction
- Using Summation Functions
- Delving into Division
- Mastering Multiplication
- Exploring Exponential and Logarithmic Functions
- Using Trigonometry Functions
- Seeing Signs
- Getting to the Root of Things
- Rounding and Truncating Numbers
- Converting Between Number Systems
- Manipulating Matrices
- Building Support for Vectors
- Using Spreadsheet Functions in VBA Code
- Dealing with Complex Numbers

Curve Fitting and Regression

- Introduction
- Performing Linear Curve Fitting Using Excel Charts
- Constructing Your Own Linear Fit Using Spreadsheet Functions
- Using a Single Spreadsheet Function for Linear Curve Fitting
- Performing Multiple Linear Regression
- Generating Nonlinear Curve Fits Using Excel Charts
- Fitting Nonlinear Curves Using Solver
- Assessing Goodness of Fit
- Computing Confidence Intervals

Solving Equations

- Introduction
- Finding Roots Graphically
- Solving Nonlinear Equations Iteratively
- Automating Tedious Problems with VBA
- Solving Linear Systems
- Tackling Nonlinear Systems of Equations
- Using Classical Methods for Solving Equations

Numerical Integration and Differentiation

- Introduction
- Integrating a Definite Integral
- Implementing the Trapezoidal Rule in VBA
- Computing the Center of an Area Using Numerical Integration
- Calculating the Second Moment of an Area
- Dealing with Double Integrals
- Numerical Differentiation

Solving Ordinary Differential Equations

- Introduction
- Solving First-Order Initial Value Problems
- Applying the Runge-Kutta Method to Second-Order Initial Value Problems
- Tackling Coupled Equations
- Shooting Boundary Value Problems

Solving Partial Differential Equations

- Introduction
- Leveraging Excel to Directly Solve Finite Difference Equations
- Recruiting Solver to Iteratively Solve Finite Difference Equations
- Solving Initial Value Problems
- Using Excel to Help Solve Problems Formulated Using the Finite Element Method

Performing Optimization Analyses in Excel

- Introduction
- Using Excel for Traditional Linear Programming
- Exploring Resource Allocation Optimization Problems
- Getting More Realistic Results with Integer Constraints
- Tackling Troublesome Problems
- Optimizing Engineering Design Problems
- Understanding Solver Reports
- Programming a Genetic Algorithm for Optimization

Introduction to Financial Calculations

- Introduction
- Computing Present Value
- Calculating Future Value
- Figuring Out Required Rate of Return
- Doubling Your Money
- Determining Monthly Payments
- Considering Cash Flow Alternatives
- Achieving a Certain Future Value
- Assessing Net Present Worth
- Estimating Rate of Return
- Solving Inverse Problems
- Figuring a Break-Even Point

Index

Excel Scientific and Engineering Cookbook (Cookbooks (OReilly))

ISBN: 0596008791

EAN: 2147483647

EAN: 2147483647

Year: N/A

Pages: 206

Pages: 206

Authors: David M Bourg

Similar book on Amazon

Flylib.com © 2008-2020.

If you may any questions please contact us: flylib@qtcs.net

If you may any questions please contact us: flylib@qtcs.net