CS395T/CAM383M Computational Statistics > HW 2 HW 2 solution
 Register FAQ Calendar Search Today's Posts Mark Forums Read

#1
02-15-2010, 11:12 AM
 jhussmann TA Join Date: Jan 2009 Posts: 76
HW 2 solution

Here is the Mathematica notebook used in the discussion section.
Attached Files
 week2.nb.zip (250.1 KB, 688 views)
#2
02-23-2010, 05:44 PM
 jhussmann TA Join Date: Jan 2009 Posts: 76
HW 2 solution

Attached.

Matlab implementation:

Code:
```fid = fopen('hw2_data_small.txt', 'r');
a = fscanf(fid, '%d %d %d', [3 inf]);
a = a';
total = size(a, 1);
placements = zeros(1, 3);
opening = zeros(3, 3);

for i=1:total
placements(a(i, 1)) = placements(a(i, 1)) + 1;
if (a(i, 1) == a(i, 2))
opening( a(i, 2), a(i, 3) ) = opening( a(i, 2), a(i, 3) ) + 1;
end
end

model1= @(x,a,b) x.^a.*(1-x).^b ./ (gamma(1+a)*gamma(1+b)/gamma(2+a+b));
model2 = @(x,y,a,b,c) x.^a.*y.^b.*(1-x-y).^c ./ (gamma(1+a)*gamma(1+b)*gamma(1+c)/gamma(3+a+b+c));

car1 = @(x,y) x.*model2(x,y,placements(1),placements(2),placements(3));
car2 = @(x,y) y.*model2(x,y,placements(1),placements(2),placements(3));
car3 = @(x,y) (1-x-y).*model2(x,y,placements(1),placements(2),placements(3));

cars = {car1, car2, car3};
opens = {@(x,a,b) x.*model1(x,a,b), @(x,a,b) (1-x).*model1(x,a,b)};
offset = [-1 1];

for pick=0:2   %picks are numbered 0-2 rather than 1-3 to make mod 3 arithmetic easier
disp(['pick door ' num2str(pick+1)]);
probs = zeros(2);
for i = 1:2
%evaluate switching if he opens (pick + i) mod 3
%evaluate staying for same pick
end
disp(['switch if he opens ', num2str(mod(pick+1,3)+1), ', switch if he opens ', num2str(mod(pick+2,3)+1), ', expected win rate = ', num2str(probs(1,1)+probs(2,1))])
disp(['switch if he opens ', num2str(mod(pick+1,3)+1), ', stay if he opens ', num2str(mod(pick+2,3)+1), ', expected win rate = ', num2str(probs(1,1)+probs(2,2))])
disp(['stay if he opens ', num2str(mod(pick+1,3)+1), ', switch if he opens ', num2str(mod(pick+2,3)+1), ', expected win rate = ', num2str(probs(1,2)+probs(2,1))])
disp(['stay if he opens ', num2str(mod(pick+1,3)+1), ', stay if he opens ', num2str(mod(pick+2,3)+1), ', expected win rate = ', num2str(probs(1,2)+probs(2,2))])
end```
Attached Images
 hw2_sol.pdf (65.8 KB, 642 views)
#3
02-23-2010, 06:46 PM
 Saurabh Member Join Date: Jan 2010 Posts: 25

I assume that the dataset was generated by you. If so,could you also post how you generated it?

 Thread Tools Display Modes Linear Mode

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is On HTML code is Off Forum Rules
 Forum Jump User Control Panel Private Messages Subscriptions Who's Online Search Forums Forums Home CS395T/CAM383M (Spring 2011) Course Administration     Announcements (click here and read!)     Basic Course Information     Supplementary Materials CS395T/CAM383M (Spring 2011) Lectures and Student Participation     Lecture Slides     Other Topics and Student Contributions     Homework Assignments and Student Postings         HW 1         HW 2         HW 3         HW 4         HW 5         HW 6     Student Term Projects Previous year: Spring, 2010     Announcements     Basic Course Information     Supplementary Materials     Lecture Slides     Other Topics and Student Contributions     Homework Assignments and Student Postings         HW 1         HW 2         HW 3         HW 4         HW 5         HW 6     Student Term Projects Previous year: Spring, 2009     Basic Course Information     Supplementary Materials     Lecture Slides     Student Term Projects

All times are GMT -6. The time now is 06:18 AM.

 www.wpressutexas.net - Archive - Top