Skip to content

Commit

Permalink
가볍게 ANOVA 영상에 Background 넣음
Browse files Browse the repository at this point in the history
  • Loading branch information
angeloyeo committed Nov 15, 2021
1 parent a631a76 commit c152ad5
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 33 deletions.
Binary file added 통계학/가볍게_ANOVA/background.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified 통계학/가볍게_ANOVA/mu_away.mp4
Binary file not shown.
Binary file modified 통계학/가볍게_ANOVA/mu_closer.mp4
Binary file not shown.
109 changes: 76 additions & 33 deletions 통계학/가볍게_ANOVA/my_animation.m
Original file line number Diff line number Diff line change
Expand Up @@ -5,35 +5,51 @@
xx = linspace(-10, 10, n_step); % 20 fr/s for 3 seconds
xx = sigmoid(xx);

% my_fun = @(x) -1/5 * sin(2*pi*x/3) + x/3;
% tt = linspace(0, 3, n_step);
% xx = my_fun(tt);
% figure; plot(tt, xx)

%% When mu's get away from each other
mu1 = [-2, 1, 2];
mu2 = [-4, 2, 5];

x = linspace(-10,10,1000);
figure('position', [1921, 41, 1920, 1080], 'color', 'w');
figure('position', [1921, 41, 1920, 1080], 'color', 'w');

newVid = VideoWriter('mu_away', 'MPEG-4'); % New
newVid.FrameRate = 20;
newVid.Quality = 100;
open(newVid);

for i_step = 1:n_step


axes('position',[0, 0, 1, 1])

I = imread('background.png');
h = image(xlim, ylim, I);

uistack(h, 'bottom')

axes('position', [0.13, 0.33, 0.75, 0.33])

yy1 = normpdf(x, xx(i_step) * (mu2(1)-mu1(1)) + mu1(1), 1);
yy2 = normpdf(x, xx(i_step) * (mu2(2)-mu1(2)) + mu1(2), 1);
yy3 = normpdf(x, xx(i_step) * (mu2(3)-mu1(3)) + mu1(3), 1);
set(gca,'position', [0.13, 0.33, 0.75, 0.33])
plot(x, yy1,'linewidth',3);
plot(x, yy1,'linewidth',4);
hold on;
plot(x, yy2,'linewidth',3);
plot(x, yy3,'linewidth',3);
plot(x, yy2,'linewidth',4);
plot(x, yy3,'linewidth',4);
xlabel('$$x$$','interpreter','latex');
ylabel('pdf','interpreter','latex');
grid on;
set(gca,'fontsize',12);
set(gca,'fontname','나눔고딕')
set(gca,'visible','off')

writeVideo(newVid, getframe(gcf));

drawnow;
if i_step < n_step
cla
Expand All @@ -50,31 +66,41 @@
mu2 = [-0.2, 0.5, 1.2];

x = linspace(-10,10,1000);
figure('position', [1921, 41, 1920, 1080], 'color', 'w');
figure('position', [1921, 41, 1920, 1080], 'color', 'w');

newVid = VideoWriter('mu_closer', 'MPEG-4'); % New
newVid.FrameRate = 20;
newVid.Quality = 100;
open(newVid);

for i_step = 1:n_step


axes('position',[0, 0, 1, 1])

I = imread('background.png');
h = image(xlim, ylim, I);

uistack(h, 'bottom')

axes('position', [0.13, 0.33, 0.75, 0.33])

yy1 = normpdf(x, xx(i_step) * (mu2(1)-mu1(1)) + mu1(1), 1);
yy2 = normpdf(x, xx(i_step) * (mu2(2)-mu1(2)) + mu1(2), 1);
yy3 = normpdf(x, xx(i_step) * (mu2(3)-mu1(3)) + mu1(3), 1);

set(gca,'position', [0.13, 0.33, 0.75, 0.33])
plot(x, yy1,'linewidth',3);

plot(x, yy1,'linewidth',4);
hold on;
plot(x, yy2,'linewidth',3);
plot(x, yy3,'linewidth',3);
plot(x, yy2,'linewidth',4);
plot(x, yy3,'linewidth',4);
xlabel('$$x$$','interpreter','latex');
ylabel('pdf','interpreter','latex');
grid on;
set(gca,'fontsize',12);
set(gca,'fontname','나눔고딕')
set(gca,'visible','off')

writeVideo(newVid, getframe(gcf));

drawnow;
if i_step < n_step
cla
Expand All @@ -90,7 +116,7 @@
sig1 = [2, 1, 1.5];
sig2 = [0.2, 0.1, 0.2];
x = linspace(-10,10,1000);
figure('position', [1921, 41, 1920, 1080], 'color', 'w');
figure('position', [1921, 41, 1920, 1080], 'color', 'w');

newVid = VideoWriter('sig_smaller', 'MPEG-4'); % New
newVid.FrameRate = 20;
Expand All @@ -99,26 +125,36 @@


for i_step = 1:n_step


axes('position',[0, 0, 1, 1])

I = imread('background.png');
h = image(xlim, ylim, I);

uistack(h, 'bottom')

axes('position', [0.13, 0.33, 0.75, 0.33])

yy1 = normpdf(x, mu1(1), xx(i_step) * (sig2(1)-sig1(1)) + sig1(1));
yy2 = normpdf(x, mu1(2), xx(i_step) * (sig2(2)-sig1(2)) + sig1(2));
yy3 = normpdf(x, mu1(3), xx(i_step) * (sig2(3)-sig1(3)) + sig1(3));

set(gca,'position', [0.13, 0.33, 0.75, 0.33])
plot(x, yy1,'linewidth',3);

plot(x, yy1,'linewidth',4);
hold on;
plot(x, yy2,'linewidth',3);
plot(x, yy3,'linewidth',3);
plot(x, yy2,'linewidth',4);
plot(x, yy3,'linewidth',4);
xlabel('$$x$$','interpreter','latex');
ylabel('pdf','interpreter','latex');
grid on;
set(gca,'fontsize',12);
set(gca,'fontname','나눔고딕')
ylim([0, 1.2])

set(gca,'visible','off')

writeVideo(newVid, getframe(gcf));


ylim([0, 1.2])

drawnow;
if i_step < n_step
cla
Expand All @@ -134,7 +170,7 @@
sig1 = [0.2, 0.1, 0.2];
sig2 = [3, 4, 2];
x = linspace(-10,10,1000);
figure('position', [1921, 41, 1920, 1080], 'color', 'w');
figure('position', [1921, 41, 1920, 1080], 'color', 'w');

newVid = VideoWriter('sig_bigger', 'MPEG-4'); % New
newVid.FrameRate = 20;
Expand All @@ -143,26 +179,33 @@


for i_step = 1:n_step


axes('position',[0, 0, 1, 1])

I = imread('background.png');
h = image(xlim, ylim, I);

uistack(h, 'bottom')

axes('position', [0.13, 0.33, 0.75, 0.33])

yy1 = normpdf(x, mu1(1), xx(i_step) * (sig2(1)-sig1(1)) + sig1(1));
yy2 = normpdf(x, mu1(2), xx(i_step) * (sig2(2)-sig1(2)) + sig1(2));
yy3 = normpdf(x, mu1(3), xx(i_step) * (sig2(3)-sig1(3)) + sig1(3));

set(gca,'position', [0.13, 0.33, 0.75, 0.33])

plot(x, yy1,'linewidth',3);


plot(x, yy1,'linewidth',4);
hold on;
plot(x, yy2,'linewidth',3);
plot(x, yy3,'linewidth',3);
plot(x, yy2,'linewidth',4);
plot(x, yy3,'linewidth',4);
xlabel('$$x$$','interpreter','latex');
ylabel('pdf','interpreter','latex');
grid on;
set(gca,'fontsize',12);
set(gca,'fontname','나눔고딕')
ylim([0, 0.4])

set(gca,'visible','off')
writeVideo(newVid, getframe(gcf));


drawnow;
if i_step < n_step
Expand Down
Binary file modified 통계학/가볍게_ANOVA/sig_bigger.mp4
Binary file not shown.
Binary file modified 통계학/가볍게_ANOVA/sig_smaller.mp4
Binary file not shown.

0 comments on commit c152ad5

Please sign in to comment.