Post
Topic
Board Announcements (Altcoins)
Re: [ANN] Catcoin - Scrypt meow!
by
strelok369
on 12/01/2014, 17:51:55 UTC
Look people i have some simple research on diff recalc

Code(matlab):

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clear
clc

N = 36*10+1;
hashrate   = zeros(1, N);
difficulty =  ones(1, N);
blocktime  = zeros(1, N);

lastchange = 1;
hashrate(1,1) = 1000;

%imaging floating hashrate somehow (i'm not a wizard of probability theory)
for i=2:N
   change = rand(1,1)/4*sqrt(i-lastchange);
   if change>1
      hashrate(1, i) = rand(1,1)*1000*2+100;
      lastchange = i;
   else
      hashrate(1, i) = hashrate(1, i-1);
   end
end

%hashrate   = [ones(1, (N-1)/3)*100 ones(1,(N-1)/3).*1000 ones(1, (N-1)/3+1)*100];
%single stepup stepdown
%end imaging floating hashrate somehow

%diff and approximate blocktimes with sliding window
for i=1:37
    blocktime(1,i) = (difficulty(1,i)*2^32/(hashrate(1, i)*1e6)/60);
end

for i=(37+1):N
    average  = sum(blocktime (1, (i-36):(i-1)))/36; %average of blocktimes
    averdiff = sum(difficulty(1, (i-36):(i-1)))/36; %very important, otherwise unstable
    difficulty(1,i) = averdiff/(average/10); %10 is target, such recalc have astatism
    blocktime(1,i) = (difficulty(1,i)*2^32/(hashrate(1, i)*1e6)/60);
end
%end diff and approximate blocktimes with sliding window

%show results for window
fig1 = figure(1);
stairs(hashrate./100, 'color' , 'red');
hold on
stairs(difficulty./10, 'color' , 'green');
stairs(blocktime, 'color' , 'blue');
hold off
%end show results for window

difficulty =  ones(1, N);
blocktime  = zeros(1, N);

%diff and approximate blocktimes with classic recalc
lastrecalc = 1;
for i=2:N
   if i-lastrecalc > 36
       average  = sum(blocktime (1, (i-36):(i-1)))/36;
       difficulty(1,i) = difficulty(1,i-1)/(average/10); %10 is target, such recalc have astatism
       lastrecalc = i;
   else
       difficulty(1,i) = difficulty(1,i-1);
   end
   blocktime(1,i) = (difficulty(1,i)*2^32/(hashrate(1, i)*1e6)/60);
end
%end diff and approximate blocktimes with classic recalc

fig2 = figure(2);
%show results for classic
stairs(hashrate./100, 'color' , 'red');
hold on
stairs(difficulty./10, 'color' , 'green');
stairs(blocktime, 'color' , 'blue');
hold off
%end show results for classic
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Graphs:
RED  - hashrate
GREEN - diff
BLUE - blocktime
Classic random hashrate:
http://gifti.me/i/VU1tRvI.png
Sliding window random hashrate:
http://gifti.me/i/NVtrkm.png
Step hashrate classic recalc:
http://gifti.me/i/PdguI.png
Step hashrate sliding window:
http://gifti.me/i/qBS3eE0I.png

Market reaction not implemented, profitability factor not implemented,
all values on graphs in relative "green parrots", see code to understand
real world approx values.

Matlab arrays starts from 1 not 0;

Warning: if sliding window then in next difficulty must take part average
difficulty on window, not previous difficulty, othervise system unstable.