Wednesday, March 9, 2011

Veggie Magnets with Modeling Magic

Here are some veggie themed fridge magnets that I made out of Modeling Magic. Modeling Magic is a Crayola child/baby product that I buy a lot of. It comes in primary colors and mixes easy, just like plasticine and other clay-like products for children. The great thing about Modeling Magic, which separates it from the others, is that it is SO light. It air dries and weighs next to nothing. This is great for making magnets. They can actually support something besides their own weight.







And here is the second set:



To make these it is quite simple. Mix the colors together, shape the Modeling Magic into veggies and then let is dry. The longer the better. Then I glaze them (clear or shiny-clear glaze). Lastly I stick on a magnet with Super/Krazy...etc glue. I have ruined a few magnets by gluing them to my fingers and having to sacrifice them for finger freedom.





Ecological Detective (Chapter 6)

Alright, here is the Matlab code for chapter 6 of the Ecological Detective.

% Here is the data from table 6.1, page 120 (Ecological Detective)

M=[0 0 0 0 0; 0 0 0 0 0; 0 0 0 0 0; 4 0 2 1 0; 5 0 5 1 0; 6 1 11 3 0; 7 1 5 1 0; 8 0 2 1 0; 9 0 1 0 1; 10 0 4 3 0; 11 0 3 4 0; 12 0 1 6 0; 13 1 2 4 0;14 0 0 3 1; 15 0 3 4 0; 16 0 2 6 0; 17 0 2 4 0; 18 0 0 2 0; 19 0 0 6 0; 20 0 0 2 0; 21 0 1 1 0; 22 0 0 0 0;23 0 0 1 0]


% Pseudocode 6.1

% Fixed clutch, c1

SSQ1=0;
for i=4:23
for j=1:4
SSQ1=SSQ1+(j-1)^2*M(i,j+1);
end
end


% Fixed clutch, c2

SSQ2=0;
for i=4:23
for j=1:4
SSQ2=SSQ2+(j-2)^2*M(i,j+1);
end
end

% Fixed clutch, c3

SSQ3=0;
for i=4:23
for j=1:4
SSQ3=SSQ3+(j-3)^2*M(i,j+1);
end
end

% Fixed clutch, c4

SSQ4=0;
for i=4:23
for j=1:4
SSQ4=SSQ4+(j-4)^2*M(i,j+1);
end
end


% Now to get the table (pg 124) results we scale the above values by Nc=102 (total number of observations)

Nc=102
Result=[1 SSQ1/Nc;2 SSQ2/Nc; 3 SSQ3/Nc; 4 SSQ4/Nc]






% Pseudocode 6.2

% first we get the place holders ready

SSQ=10^6;
SSQss=0;
parameters=[0 0 0];

% First we loop over all possible combinations of c1, c2, e1
% Then we generate the SSQ (sum of squares).
% Last ish we hold the smallest

for c1=1:4
for c2=1:4
for e1=4:23


for i=4:23
for j=1:4
if i>e1
SSQss=SSQss+(j-c2)^2*M(i,j+1);
else
SSQss=SSQss+(j-c1)^2*M(i,j+1);
end
end
end

if SSQssparameters=[c1 c2 e1];
SSQ=SSQss;
end

SSQss=0;

end
end
end




% Pseudocode 6.3

Just look at the statistical package in Matlab, there is a bootstrap command AND a sample with replacement command.

The Ecological Detective (Chapter 5)

As a lab group we are reading the Ecological Detective, a great book that confronts models with data blah blah blah...

Here is the pseudo code for Chapter 5, on least squares. I wrote in Matlab. You can just cut and paste this into the command window. Or save it as a .m file.

% One iteration of the Monte Carlo Method is below:
% We do this to generate a random-ish data set.

A=1;
B=0.5;
C=0.25;
w=-3+(3-(-3)).*rand(10,1) % this is code for generating ten (a vector) of random unifor variables between [-3,3]
Data=zeros(1,10) % getting an empty vector to collect our resulting Data's

for i=1:10 % this loop fills up the Data vector with values from the poly and random var
Y(i)=A+B*(i)+C*(i)^2+w(i);
end

Data

plot(Data,'o','MarkerFaceColor','g')




%%%%% Now we fit a model to the data we just generated %%%%%%%%%%%

Amin=0;Amax=3;Bmin=0;Bmax=2;Cmin=0;Cmax=1;
cat=10000000000;
ABC=[0,0,0]
x=[1 2 3 4 5 6 7 8 9 10];
for A=Amin:0.1:Amax
for B=Bmin:0.05:Bmax
for C=Cmin:0.025:Cmax
Data=[3.638342118359073 5.434751622453716 2.511920897761036 9.480255136834117 10.544155477352458 10.585242429996457 15.420989313202291 21.281289115229903 28.495041012605785 33.789331211195659];
lsq=sum(Data-(A+B*x+C*x.^2)).^2
if lsqABC=[A,B,C]
cat=lsq
end
end
end
end

ABC
plot(Data,'o','MarkerFaceColor','r')
hold on;
plot(ABC(1)+ABC(2)*x+ABC(3)*x.^2,'-k')
hold on;
plot(1+0.5*x+0.25*x.^2,'--b')

LinkWithin

Related Posts Plugin for WordPress, Blogger...