To generate two independent Gaussian random variables
This figure show total number
Learn More →
We can plot the semi-log to again verified the result.
Learn More →
For generating two independent Gaussian variables
Learn More →
Interesting happened when I generate
however when
Learn More →
Learn More →
Learn More →
Learn More →
Learn More →
Learn More →
I then use totally different random distribution consist of one-third of exponential distribution, another one-third of uniform distribution and one-third of Gaussian distribution. The parameter are given below.
As you can see it become Gaussian again when n is larger (roughly at
Learn More →
Learn More →
Learn More →
Learn More →
Learn More →
program main
implicit none
double precision, external :: gaurand
integer, parameter :: n=100000
double precision :: x(n), sig=dsqrt(.2d0)
integer :: i
do i = 1, n
x(i) = gaurand(sig)
end do
open(66, file='a.dat', status='unknown')
do i = 1, n
write(66, *) x(i)
end do
end program main
function gaurand(sig)
implicit none
double precision, parameter :: tpi=8.d0*atan(1.d0)
double precision :: a, b, gaurand, sig
call random_seed()
call random_number(a)
call random_seed()
call random_number(b)
gaurand = sig * dsqrt(-2.d0 * log(a)) * dcos(tpi * b)
end function
program clt
implicit none
integer, parameter :: n=1000, m=50
double precision :: x(n, m), y(n)
integer :: i, j
open(66, file='c50.dat', status='unknown')
call random_seed()
do i = 1, n
call random_number(x)
end do
y = 0.d0
do j = 1, m
y(:) = y(:) + x(:, j)
end do
y = y / m
do i = 1, n
write(66, *) y(i)
end do
end program clt
program clt
implicit none
double precision, external :: gaurand
integer, parameter :: n=10000, m=3
double precision :: x1(n, m), x2(n, m), x3(n, m), y(n)
integer :: i, j
double precision :: a = .2d0
open(66, file='d3.dat', status='unknown')
call random_seed()
call random_number(x1)
x1 = - 1.d0 / a * dlog(x1)
call random_number(x2)
do j = 1, m
do i = 1, n
x3(i, j) = gaurand(dsqrt(.2d0))
end do
end do
y = 0.d0
do j = 1, m
y(:) = y(:) + x1(:, j) + x2(:, j)+ x3(:, j)
end do
y = y / m
do i = 1, n
write(66, *) y(i)
end do
end program clt
function gaurand(sig)
implicit none
double precision, parameter :: tpi=8.d0*atan(1.d0)
double precision :: a, b, gaurand, sig
call random_seed()
call random_number(a)
call random_seed()
call random_number(b)
gaurand = sig * dsqrt(-2.d0 * log(a)) * dcos(tpi * b)
end function
Ising model on square lattice are L \times L spin that can take 2 values, either S_i=+1 or S_i=-1. Each spin interact with neighbors and with external field. The Hamiltonian of the system is\begin{equation} H = -\sum_{<ij>} J_{ij}S_iS_j - \sum_i H_iS_i \end{equation}A particular solution for no external field are obtained by Lars Onsager where the second-order phase transition is happened at\dfrac{J}{k_BT_c} = \dfrac{ln(1+\sqrt{2})}{2}. With this in mind, we can use Metropolis algorithm to simulate Ising model with good accuracy. Following four figures show different MC steps, the spin of a 100 \times 100 system with blue represent spin up and red represent spin down. Since the temperature happened around the critical temperature, the magnetization taken very long time to come to equilibrium.
Mar 16, 2023Non-reversal random walk are randomly walk except it cannot reverse it's previous step. Following two figures show different steps of NRRW, compare to previous figure it can walk further since it cannot go reverse its previous step.
Mar 16, 2023An ideal 1 dimension random walk with probability of p stepping to right and 1-p to the left are represented by below figure of numbers of particle of first 100 steps. From this we can clearly guess(see) that the probability P(x, N) at N step at location x are higher around the center and lower at the edge, just like a Gaussian distribution.
Mar 16, 2023Poisson equation has the form of\begin{equation} \dfrac{\partial^2 u}{\partial x^2}+\dfrac{\partial^2 u}{\partial y^2} = -\dfrac{q}{K} \tag{1} \end{equation}In this particular case u is the steady-state temperature. Given the boundary condition we can apply finite difference into this PDE and solve it numerically. The finite difference has the following relation.\begin{equation} w_{ij} = \dfrac{1}{2+2\left( \dfrac{h}{j}\right)^2} \left[ w_{i+1,j} + w_{i-1,j} + (\dfrac{h}{k})^2(w_{i,j+1}+w_{i,j-1}) -h^2f_{ij} \right] \tag{2} \end{equation}Instead of solving this linear equation, we were using relaxation method to solve it which is let the solution iterate until it reach a desired tolerance. Follow figure show the temperature distribution in x-y plane with line represent the isotherm area. The area around x and y axis is what we expected that the center are the hottest and gradually cool down to another two boundary.
Mar 15, 2023or
By clicking below, you agree to our terms of service.
New to HackMD? Sign up