This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
from numpy import pi | |
import matplotlib.pyplot as plt | |
import matplotlib.animation as animation | |
fig = plt.figure() | |
fig.set_dpi(100) | |
ax1 = fig.add_subplot(1,1,1) | |
#Diffusion constant |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
############################################################################### | |
# Confidence intervals for the population mean (t-student distribution) | |
# We assume that | |
# 1. Data is normally distributed | |
# 2. Samples are iid | |
# | |
# Note that population variance is unknown and therefore must be | |
# estimated. In this case Student distribution should be used. | |
# The number of degree of freedom is n-1 where n is the size of | |
# the sample. Note that as n -> Inf the Student distribution tends to |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
############################################################################### | |
# The code below can be used to perform a z-test under the following | |
# assumptions: | |
# 1. The data is normally distributed | |
# 2. Samples are iid | |
# | |
# Remember that: | |
# 1.Low pvalue: strong empirical evidence against h0 | |
# 2.High pvalue: little or 'no' empirical evidence against h0 | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Plot of the Student distribution | |
dfs <- length(data_vector)-1 | |
x_ <- seq(-8,8,0.1) | |
y <- dt(x_,dfs) | |
t.val <- qt(1-0.05,df=dfs) | |
plot(x_,y,type='l',lwd=3,col='blue',xlab='x',ylab='Density',main='Student distribution 9 dof') | |
abline(v=0) | |
abline(v=t.val,lwd=2,col='red') | |
points(t.val,dt(t.val,dfs),lwd=3,col='red') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% Set up | |
x = -4:0.2:4; | |
y1 = -4:0.2:4; | |
y = (-4:0.2:4)*1i; | |
[X, Y]= meshgrid(x,y); | |
% Complex variable s | |
s = X + Y; | |
% Complex function f(z) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%%Gradient and flow | |
figure | |
subplot(1,2,1); | |
[Dx, Dy] = gradient(real(z)); | |
Dx(isinf(Dx)) = 0; | |
Dy(isinf(Dy)) = 0; | |
hQuiver = quiver(x,y1,Dx,Dy,'LineWidth',1); hold on; | |
viscircles([0 0],1,'LineWidth',1); hold off; | |
title('u(x,y) gradient, vector field'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
figure | |
subplot(1,3,1) | |
C1 = contour(x,y1,abs(z),linspace(-10,10,100)); title('Contour of abs(f)'); | |
xlabel('x'); ylabel('y'); %clabel(C1); | |
subplot(1,3,2) | |
C2 = contour(x,y1,real(z),linspace(-10,10,100)); title('Contour of re(f)'); | |
xlabel('x'); ylabel('y'); %clabel(C2); | |
subplot(1,3,3) | |
C3 = contour(x,y1,imag(z),linspace(-10,10,100)); title('Contour of Im(f)'); | |
xlabel('x'); ylabel('y'); %clabel(C3); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Simulated data (normal and beta distributions) | |
set.seed(70) | |
data_norm <- rnorm(100,0,1) | |
data_beta <- rbeta(1000,2,30)*10 | |
# Compare the boxplots | |
boxplot(data_norm,data_beta,col='cyan') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Skewness | |
library(moments) | |
print("Skewness:") | |
print("Normal") | |
skewness(data_norm) | |
print("Beta") | |
skewness(data_beta) | |
# < 0 skewed left (left tail) | |
# > 0 skewed right (right tail) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Compare the histograms | |
hist(data_norm,col='red') | |
hist(data_beta,col='blue') |