MATLAB Code
Original FM
function dy = wire(p)% This subroutine accepts a vector that contains all the% parameters used in the wire. These parameters do not account% the smoothing parameter. The number of interpolating points% is automatically calculated from the vector length.% Examples:% pattern = wire([x y d1 d2 p]);% resolution of the pattern (# bins in histogram)nbins = 365;% duration of chaos gamendots = 2^14;% # of interpolating pointsintp = (7+length(p))/4;% y in [-5,5]% d in [-1,1]% Put the parameters into neat little vectors.xs = [0 p(1:(intp-2)) 1];ys = [0 p((intp-1):(2*intp-4)) 1];d = 2*p((2*intp-3):(3*intp-5));ps = [0 p((3*intp-4):(4*intp-7)) 1];% Validation required when >3 interpolating ptsif intp>3% x-values must be in increasing orderfor vx=2:(length(xs)-2)if xs(vx) >= xs(vx+1)dy = ones(1,nbins) / nbins;returnendend% p-values must be in increasing orderfor vp=2:(length(ps)-2)if ps(vp) >= ps(vp+1)dy = ones(1,nbins) / nbins;returnendendend% Calculate the other parameters of the map.h = xs(end)-xs(1);a =(xs(2:end)-xs(1:end-1))/h;e = xs(1:end-1)-xs(1)*a;c =(ys(2:end)-ys(1:end-1)-d*(ys(end) - ys(1)))/h;f = ys(1:end-1)-d*ys(1)-c*xs(1);% Determine when to use which map during the chaos game.W = zeros(ndots,1);prob = rand(ndots,1);for k=1:(length(ps)-1)W = W + and(prob<ps(k+1),prob>ps(k))*k;endkfun = sum(W,2);y = zeros(ndots,1);xold = xs(2);yold = ys(2);y(1) = yold;for i=1:ndots-1k = max(min(kfun(i),numel(a)),1);xnew = a(k)*xold + e(k);ynew = c(k)*xold + d(k)*yold + f(k);xold = xnew;yold = ynew;y(i+1) = ynew;end% Create histogram.dy = hist(y, nbins);% Normalize histogram so that the area underneath = 1dy = dy/sum(dy);% End.
Extension to overlap
function dy = leaf(p)% This subroutine accepts a vector that contains all the% parameters used in the overlapped leafy attractor. These% parameters do not account smoothing one. The number of% mappings is automatically calculated from the vector length.% Examples:% pattern = leaf([x1 x2 y1 y2 d1 d2 p]);% resolution of the pattern (# bins in histogram)nbins = 365;% duration of chaos gamendots = 2^14;% # of mapsnobj = (5+length(p))/6;% y in [-5,5]% d in [-1,1]% Put the parameters into neat little vectors.xs = [0 p(1:(2*nobj-2)) 1];ys = [0 p((2*nobj-1):(4*nobj-4)) 1];d = p((4*nobj-3):(5*nobj-4));ps = [0 p((5*nobj-3):(6*nobj-5)) 1];% Validation required when >2 mapsif nobj>2% interval spans must be positivefor vx=3:2:(length(xs)-3)if xs(vx) >= xs(vx+1)dy = ones(1,nbins) / nbins;returnendend% p-values must be in increasing orderfor vp=2:(length(ps)-2)if ps(vp) >= ps(vp+1)dy = ones(1,nbins) / nbins;returnendendend% Calculate the other parameters of the map.h = xs(end)-xs(1);a =(xs(2:2:end)-xs(1:2:end-1))/h;e = xs(1:2:end-1)-xs(1)*a;c =(ys(2:2:end)-ys(1:2:end-1)-d*(ys(end)-ys(1)))/h;f = ys(1:2:end-1)-d*ys(1)-c*xs(1);% Determine when to use which map during the chaos game.W = zeros(ndots,1);prob = rand(ndots,1);for k=1:(length(ps)-1)W = W + and(prob<ps(k+1),prob>ps(k))*k;endkfun = sum(W,2);y = zeros(ndots,1);xold = xs(2);yold = ys(2);y(1) = yold;for i=1:ndots-1k = max(min(kfun(i),numel(a)),1);xnew = a(k)*xold + e(k);ynew = c(k)*xold + d(k)*yold + f(k);xold = xnew;yold = ynew;y(i+1) = ynew;end% Create histogram.dy = hist(y, nbins);% Normalize histogram so that the area underneath = 1dy = dy/sum(dy);% End.
Online Demo
Wire with 2 maps
Parameters below may be modified to draw FM outcomes dys. When the parameter Smoothness equals 1 the raw Fractal-Multifractal shadow dy is found.
Overlap with 2 maps
Parameters below may be modified to draw FM outcomes dys. When the parameter Smoothness equals 1 the raw Fractal-Multifractal shadow dy is found.