A) Assume that during a particular hour the following 37 bids (demand = load) were observed in the NordPool (first entry is Load in 1000 MWh (= Q), and second entry is €/MWh (= P)).

datainitial={{24,30.7},{23.5,36},{22.6,30},{22.5,30},{22,30},{21.5,31},{21.5,40.2},
{21.5,29.8},{23,29.6},{23.7,30.5},{24,30},{24.2,34},{25.2,30.2},{25.5,30.5},{23.5,41.2},
{22,32.5},{23.5,30.7},{24.5,31},{22.8,34},{22.7,36.8},{23.5,30.2},{25,29.5},{22.5,35.5},
{23,30.5},{22.5,45},{22,57},{21.7,75},{25.1,30.1},{23.2,43.2},{22,36.5}};

Estimate the demand elasticity for system price (equilibrium) of 22.045€/MWh, assuming the demand function is given by: (i) Q= A(P^b );(ii) Q=A+bP

(B) Suppose that the consumption of electricity per hour, during a normal day (starting at 00.00), by all villa owners (type 1) and the factories (type 2) is given in the following table. Estimate the peak load for the 95% and 99% probability level. Type 1:{1,1,1,1,2,2,2,3,2.5,2,1.5,1,1,1,1,2,2,4,5,6,5,4,2,1}
Type 2: {5,5,5,5,5,5,8,24,28,33,33,33,33,32,32,32,32,26,20,15,10,6,6,4}

A) To estimate the demand elasticity for the system price, we need to use the demand function given. There are two forms of the demand function provided:

(i) Q = A(P^b)
(ii) Q = A + bP

Let's start with the first form:

(i) Q = A(P^b)

To estimate the demand elasticity, we need to calculate the partial derivative of Q with respect to P and then divide it by Q/P.

To calculate this derivative, we differentiate Q = A(P^b) with respect to P:

dQ/dP = Ab(P^(b-1))

Next, we divide this derivative by Q/P to get the demand elasticity:

Elasticity = (dQ/dP) * (P/Q)

Now, let's substitute the given values:

Q = Load (in 1000 MWh) = datainitial[[All, 1]]
P = Price in €/MWh = datainitial[[All, 2]]
A = unknown constant
b = unknown constant

Once we calculate the values for A and b, we can use them to estimate the demand elasticity for the given system price of 22.045€/MWh.

Moving on to the second form of the demand function:

(ii) Q = A + bP

To estimate the demand elasticity using this form, we need to calculate the derivative of Q with respect to P and then divide it by Q/P.

To do this, we differentiate Q = A + bP with respect to P:

dQ/dP = b

Again, we divide this derivative by Q/P:

Elasticity = (dQ/dP) * (P/Q)

To estimate the demand elasticity using this form, we need the values for A and b, which can be calculated using the given data.

B) To estimate the peak load for the 95% and 99% probability level, we need to sort the data for type 1 and type 2 separately and then find the values that correspond to the respective probability levels.

Let's start with Type 1:
1. Sort the consumption data for Type 1 in ascending order.
2. Find the value that corresponds to the 95th percentile (0.95 probability level) by multiplying the total number of data points by 0.95 and taking the integer part.
3. Find the value that corresponds to the 99th percentile (0.99 probability level) using the same process.

Repeat the same steps for Type 2 data to estimate the peak load for the 95% and 99% probability levels.

By following these steps, you can estimate the peak load for the desired probability levels based on the given consumption data.