This is a mathematical problem with application to microeconomics. It
assumes that the the purchase response (the number of people who buy
an item) or "Demand" will decrease as the price increases. The logit
price-response function, a very popular way of modeling this decrease,
is as follows:
d(p) = C * e^-(a+b*p) / ( 1 + e^-(a+b*p) )
Here a, b, and C are parameters with C > 0 and b > 0. a can be either
greater than or less than 0. Broadly speaking, C indicates the size
of the overall market and b specifies price sensitivity. Larger
values of b correspond to greater price sensitivity. The
price-response curve is steepest in slope at the point -(a/b). The
curve is a reverse S-shaped, or sigmoid, price-response curve.
There is a related curve called the willingness-to-pay distribution.
Its formula is:
w(p) = K * e ^ -(a+b*p) / ( 1 + e ^ -(a+b*p) )^2
Logit willingness-to-pay follows a curve known as the logistic
distribution. The logistic distribution is similar to the normal
distribution, except it has somewhat "fatter tails"--that is, it
approaches zero more slowly at very high and very low values. The
highest point (mode) of the logistic willingness-to-pay distribution
occurs at -(a/b), which is also the point at which the slope of the
price-response function is steepest.
You are provided with the response data for samples of the population
at N price points, where N >= 2 and N <= 50. This response data tells
you how many people purchased a product at that price point out of how
many people considered purchasing the product at that price point. We
will not assume that the only reason these people did not purchase is
that the price was above their maximum willingness-to-pay; however, we
may assume that those who purchased did so at or below their maximum
willingness-to-pay. Thus, part of the problem may be (or this might
be irrelevant) to determine what percentage of those who consider a
product are actually "in the market" and what percentage are just
browsers and, for whatever reason, wouldn't buy.
Example data would be (with N as low as 3):
Price point $2: 120 of 840 purchased.
Price point $5: 110 of 1000 purchased.
Price point $10: 30 of 600 purchased.
Your answer should contain an algorithm for taking data in the format
of the example data (with N price points where N >= 2 and N <= 50) and
providing a best-approximation of the price-response function and
willingness-to-pay distribution. You may write with pseudocode or
with a specific programming language (Java or Haskell for example) and
comments. Comments for clarity are important. Your input is an array
with data like the example (price point $, resultant observed purchase
response relative to those with an opportunity to purchase [x out of y
people purchased]). Your output is at a minimum the values a and b.
You may also provide C or K. For an outstanding answer, please also
return a price P where the value of P*d(P) is at its maximum.