How to calculate the expected value of a formula containing several variables and constrains?

5 views (last 30 days)
Hi everyone,
I have never used MatLab before, so maybe this is not the right way to get started but I really need Matlab for only one purpose at the moment.
I do have a prediction of the individuals' underlying utility functions, which obviously depend on the individual's decisions. These decisions areare subject to several constraints (i.e. the amount they are able to choose to donate etc.). Plus, there are several factors that are fixed on the individual level and are thus not subject to individual decision making during the experiment, but they of course influence individual utility.
I would like to simulate the expected utilities of this theoretical prediction given both normal distribution and uniform distribution.
The formula is as follows:
U = Income + (2x - K)² + BETA*(2x + y)²
Income is a fixed number for everyone that can adopt two values (let's say either 50 or 100) with a probability of 50%. The upper case variables (K and BETA) are the individually fixed values, which in this case are of the following form: K is a positive real number 0<= K <= 100, BETA ranges between [0,1].
The lower case variables (x and y) are subject to the individual decision making and range between 0 and 100 in steps of 10. This means, that only the values 0, 10, 20...100 are feasible. Both, x and y, are choices made by the individual. However, these are two independent choices, which both enter the utility function.
Now, I would like to assess the expected individual utilities given that the individuals draw those numbers either from a normal distribution (case 1) or from a uniform distribution (case 2).
In addition, is there a feasible way to visualize the draws to see the outcomes?
I would really be happy if someone could provide me guidance on how to implement this problem in Matlab.
With best regards, Ed

Answers (1)

Star Strider
Star Strider on 21 Apr 2014
Edited: Star Strider on 21 Apr 2014
Here’s how I would do it. Change as necessary to do what you want:
X = 0:10:100;
Y = X;
U = @(x,y,Inc,BETA,K) Inc + (2.*x - K).^2 + BETA.*(2.*x + y).^2;
for k1 = 1:2 % Define cases
for k2 = 1:100 % Create 100 samples for each case
Inc = randi(2)*50; % Define income
B = rand;
K = randi(101)-1;
if k1 == 2 % Uniform Distribution
x = X(randi(10));
y = Y(randi(10));
else % Normal Distribution
% SclN01 = max(min(fix(normrnd(5,5)),11),1)
x = X(max(min(fix(5+5.*randn),11),1));
y = Y(max(min(fix(5+5.*randn),11),1));
end
R(k1,k2) = U(x,y,Inc,B,K); % Result array
end
end
figure(1)
plot(R(1,:), '.r')
hold on
plot(R(2,:), '.b')
hold off
xlabel('Iteration')
ylabel('U')
grid
figure(2)
hist(R', 11)
xlabel('U')
ylabel('Number')
legend('Case 1 (Normal)', 'Case 2 (Uniform)')
grid
I included a scatterplot (figure(1)) and a histogram plot (figure(2)). (You can comment-out or remove the SclN01 line. I included it because it demonstrates how the normal distribution functions, and limits the range from 1 to 11, the sizes of the X and Y vectors.)
  8 Comments
ED
ED on 22 Apr 2014
Thank you a lot, that really helped me and now I do have a better understanding of how to run my own simulations :-)

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!