**Objective**:
To
develop a procedure for randomly allocating chocolate chips to cookies
using a probability experiment employing the Monte Carlo technique. (For
a general description of the Monte Carlo technique go to the Elementary
Probability Demo Collection.)
**Level: **High
school or precalculus, or probability courses for math majors.

**Prerequisites:
**Basic
probability concepts; knowledge of equally likely chance and the chance
of winning a lottery.

**Platform: **A
calculator or computer which has a function that
generates random numbers.

**Instructor's
Notes:**
This demo is an __allocation simulation__ that
uses the Monte Carlo technique. That is, we have a certain resource that
is to be distributed in a random manner. We want to approximate the probability
of certain outcomes. Here we consider randomly distributing chocolate chips
to cookies.

A cookie manufacturer bakes a batch of 100 cookies
and decides to randomly allocate 150 chocolate chips to the batch. For
advertising and quality control, the manufacturer wants to estimate the
(average) number of cookies in a batch that will have no chocolate chips.

A way to simulate the allocation of the chocolate
chips to the cookies is to imagine that the batch of 100 cookies is arranged
in a table consisting of 10 rows and 10 columns. Using this __model__
for the batch, each cookie can be located by its row-column position. We
generate pairs of random numbers (x, y) where both x and y are integer
values from 1 to 10. Each time a particular (x, y) pair is generated we
add 1 to the table entry at that location.

After the 150 chips have been allocated, we count
the number of cookies with no chips. An estimate of the average number
of cookies in a batch of 100 to which 150 chips are allocated that contain
no chips. Figure 1 shows one such allocation where the red zeros indicate
the cookies with no chips.

In this simulation there are 20 cookies with no
chips and the largest number of chips allocated to one cookie is 4.

**
Figure 1.**
By repeating the procedure a large number
of times we can obtain a good estimate of the average number of cookies
with no chips for a batch of 100 that are randomly allocated 150 chips.
The Matlab routine chipsim.ZIP (click to download)
implements the strategy outlined above. We repeated the simulation 10 times
using a batch of 100 cookies with an allocation of 150 chips. The results
are displayed in the following table.

The animation below shows a typical simulation
of the random allocation process.

This simulation could be modified in a variety
of ways. The Matlab routine chipsim (cited above) lets the user specify
the number of chips to allocate to the 100 cookies. Selecting a different
number of chips to allocate will change the estimates of the number of
the 100 cookies that, on the average, contain no chips. Another way to
modify the simulation is to change the number of cookies in a batch. In
general, simulations of this type provide an estimate of the probability
of selecting a cookie with no chip from a batch of N cookies to which C
chips have been randomly allocated. The estimate is computed by the ratio

In advanced courses, theoretical
techniques can be used to compute the such probabilities. For example,
the following table gives the theoretical probabilities as indicated for
a batch of 100 cookies randomly allocated 150 chips.

__Reference:__ W.E. Haigh, "Using Microcomputers
to Solve Probability Problems", *Mathematics Teacher*, v78,
No.2, 1985, pp124-126

**Credits**:
This demo was submitted by

W.E.
Haigh

Department of Mathematics

Northern State University

and is included in **Demos
with Positive Impact** with his permission.

We also acknowledge contributions by Un
Jung Sin , student at Temple University. The Matlab routine chipsim was
written by David R. Hill.