Main Page | Report this Page
 
   
Science Forum Index  »  Fractals Science Forum  »  Fractional Brownian Motion Source Code...
Page 1 of 1    
Author Message
alessandro.vivas at (no spam) gmail.com...
Posted: Wed Jul 16, 2008 9:41 am
Guest
Hello, I'm want simulate the fractional Brownian motion but I didn't
found not yet. When I found I code or algorithm to simulate the fBm?

Thanks
Sjouke Burry...
Posted: Wed Jul 16, 2008 5:59 pm
Guest
alessandro.vivas at (no spam) gmail.com wrote:
Quote:
Hello, I'm want simulate the fractional Brownian motion but I didn't
found not yet. When I found I code or algorithm to simulate the fBm?

Thanks
This is fortran, a random particle walk program, where particles

diffuse into neighbouring space.
I hope you can use the algoritm,from the book of Margolus and Toffoly.
(You might buy it Smile )
-------------------------------------------------------
cc 'difuse1.for' 2 phase diffusion algorithm from margolus and toffoly.
include 'FGRAPH.FI'
include 'FGRAPH.FD'
character toets*1
integer*1 a(0:319,0:199),phase,idum(64004),k1,k2,k3,k4
integer*2 dummy
integer*4 pal
equivalence(idum(5),a(0,0))
dummy= setvideomoderows($mres256color,25)
call clearscreen($gclearscreen)
phase=0
pal=63
dummy=remappalette(1,pal)
pal=256*63
dummy=remappalette(2,pal)
pal=256*63+63
dummy=remappalette(3,pal)
pal=256*256*63
dummy=remappalette(4,pal)
pal=256*256*63+63
dummy=remappalette(5,pal)
pal=256*256*63+256*63
dummy=remappalette(6,pal)
pal=256*256*63+256*63+63
dummy=remappalette(7,pal)
call getimage(0,0,319,199,idum)
c 3circles rgb combining on screen
c clear dataarray.
a=0
c put 3 overlapping circles in the dataarray,
c with the proper color mixing when overlapping.
call xorcircle(1,160,130,66,a)
call putimage(0,0,idum,$gpset)
call xorcircle(2,160-33,70,66,a)
call putimage(0,0,idum,$gpset)
call xorcircle(4,160+33,70,66,a)
c
c in a two phase structure,
c use a local 2X2 square
c
toets=char(255)
do while(toets.eq.char(255))
c
c array to screen
c
c swap current data array to screen...
call putimage(0,0,idum,$gpset)
call keychk(toets)
c
c process data array
c
phase=ieor(phase,1)
if(phase.eq.0)then
nxb=0
nxe=318
nyb=0
nye=198
else
nxb=1
nxe=319
nyb=1
nye=199
endif
do ix=nxb,nxe,2
ixx=ix+1
if(ixx.eq.320)ixx=0
do iy=nyb,nye,2
iyy=iy+1
if(iyy.eq.200)iyy=0
k1=a(ix,iy)
k2=a(ixx,iy)
k3=a(ix,iyy)
k4=a(ixx,iyy)
c Random swap of particles.
call random(x)
if(x.lt..5)then
a(ix,iy)=k3
a(ixx,iy)=k1
a(ix,iyy)=k4
a(ixx,iyy)=k2
else
a(ix,iy)=k2
a(ixx,iy)=k4
a(ix,iyy)=k1
a(ixx,iyy)=k3
endif
enddo
enddo
enddo
dummy=setvideomode($textc80)
end
c
c Fill the dataarray with a circle
c xor the pixel color with the previous pixel color.
c
subroutine xorcircle(ncol,ix,iy,ir,a)
integer*1 a(0:319,0:199)
do kr=-ir,ir
dx=sqrt(float(ir)*float(ir)-float(kr)*float(kr))
ib=float(ix)-dx
ie=float(ix)+dx
do kx=ib,ie
a(kx,iy+kr)=ieor(a(kx,iy+kr),ncol)
enddo
enddo
return
end
Francesco Potorti`...
Posted: Thu Jul 17, 2008 9:18 am
Guest
"alessandro.vivas at (no spam) gmail.com" <alessandro.vivas at (no spam) gmail.com>:
Quote:
Hello, I'm want simulate the fractional Brownian motion but I didn't
found not yet. When I found I code or algorithm to simulate the fBm?

Have a look at <http://fly.isti.cnr.it/software/#fractals>.
Notice that the method used for creating fBm is fast but approximate.
If you want a precise method, you should use ifft.
Vivas...
Posted: Thu Jul 17, 2008 11:03 am
Guest
On 16 jul, 19:59, Sjouke Burry <burrynulnulf... at (no spam) ppllaanneett.nnlll>
wrote:
Quote:
alessandro.vi... at (no spam) gmail.com wrote:
Hello, I'm want simulate the fractional Brownian motion but I didn't
found not yet. When I found I code or algorithm to simulate the fBm?

Thanks

This is fortran, a random particle walk program, where particles
diffuse into neighbouring space.
I hope you can use the algoritm,from the book of Margolus and Toffoly.
(You might buy it Smile )
-------------------------------------------------------
cc 'difuse1.for' 2 phase diffusion algorithm from margolus and toffoly.
include 'FGRAPH.FI'
include 'FGRAPH.FD'
character toets*1
integer*1 a(0:319,0:199),phase,idum(64004),k1,k2,k3,k4
integer*2 dummy
integer*4 pal
equivalence(idum(5),a(0,0))
dummy= setvideomoderows($mres256color,25)
call clearscreen($gclearscreen)
phase=0
pal=63
dummy=remappalette(1,pal)
pal=256*63
dummy=remappalette(2,pal)
pal=256*63+63
dummy=remappalette(3,pal)
pal=256*256*63
dummy=remappalette(4,pal)
pal=256*256*63+63
dummy=remappalette(5,pal)
pal=256*256*63+256*63
dummy=remappalette(6,pal)
pal=256*256*63+256*63+63
dummy=remappalette(7,pal)
call getimage(0,0,319,199,idum)
c 3circles rgb combining on screen
c clear dataarray.
a=0
c put 3 overlapping circles in the dataarray,
c with the proper color mixing when overlapping.
call xorcircle(1,160,130,66,a)
call putimage(0,0,idum,$gpset)
call xorcircle(2,160-33,70,66,a)
call putimage(0,0,idum,$gpset)
call xorcircle(4,160+33,70,66,a)
c
c in a two phase structure,
c use a local 2X2 square
c
toets=char(255)
do while(toets.eq.char(255))
c
c array to screen
c
c swap current data array to screen...
call putimage(0,0,idum,$gpset)
call keychk(toets)
c
c process data array
c
phase=ieor(phase,1)
if(phase.eq.0)then
nxb=0
nxe=318
nyb=0
nye=198
else
nxb=1
nxe=319
nyb=1
nye=199
endif
do ix=nxb,nxe,2
ixx=ix+1
if(ixx.eq.320)ixx=0
do iy=nyb,nye,2
iyy=iy+1
if(iyy.eq.200)iyy=0
k1=a(ix,iy)
k2=a(ixx,iy)
k3=a(ix,iyy)
k4=a(ixx,iyy)
c Random swap of particles.
call random(x)
if(x.lt..5)then
a(ix,iy)=k3
a(ixx,iy)=k1
a(ix,iyy)=k4
a(ixx,iyy)=k2
else
a(ix,iy)=k2
a(ixx,iy)=k4
a(ix,iyy)=k1
a(ixx,iyy)=k3
endif
enddo
enddo
enddo
dummy=setvideomode($textc80)
end
c
c Fill the dataarray with a circle
c xor the pixel color with the previous pixel color.
c
subroutine xorcircle(ncol,ix,iy,ir,a)
integer*1 a(0:319,0:199)
do kr=-ir,ir
dx=sqrt(float(ir)*float(ir)-float(kr)*float(kr))
ib=float(ix)-dx
ie=float(ix)+dx
do kx=ib,ie
a(kx,iy+kr)=ieor(a(kx,iy+kr),ncol)
enddo
enddo
return
end

Thanks for your messagem.. I will buy the book Smile
Roger Bagula...
Posted: Wed Jul 23, 2008 10:42 am
Guest
alessandro.vivas at (no spam) gmail.com wrote:

Quote:
Hello, I'm want simulate the fractional Brownian motion but I didn't
found not yet. When I found I code or algorithm to simulate the fBm?

Thanks


Here is some old true basic code:

dim c(0 to 640,0 to 480)
print"Wang and Ulenbeck Brownian combination distribution"
print" by R. L. BAGULA 20 MARCH 1997 ©"
Print "input integer: try 1"
input r
let c(0,0)=(r+1)/(2*r)
for m=1 to 19
for s= 0 to m
if s=0 then let c(m,0)=2^m*(r+1)/(2*r) else let
c(m,s)=((r+m+1)*c(m+1,s-1)/(2*r)+(r-m+1)*c(m-1,s-1)/(2*r))
print c(m,s);" ";
next s
print
next m
end
 
Page 1 of 1       All times are GMT - 5 Hours
The time now is Sat Nov 22, 2008 7:44 pm