Seismic probability. Location: Itea - Greece region



Poisson and b-value distribution. ITEA region

Ted Aspiotis 8/10/2012


Google maps locator. Itea lat/long/alt */*/* automatic pick on manual mode













Seismic history events. Display options: 2D & 3D dimensions

Magnitude (Mw) >=3







Seismic history events. Display options: 2D & 3D dimensions

Magnitude (Mw) >=5.6







Seismic history events. Display options: 2D & 3D dimensions

Magnitude (Mw) >=6.5










Seismic Events Probability. Next peak: 2012







Historical Seismic Event Probability. Starts 1992/ Next peak: 1995 / Error 0 Years










Gutenberg Richter b value / Coulomb stress on Earth's material / Fault hazzard










Seismographs - Seismometers - Accelerographs










Potential Seismic movement afrer an earthquake. Itea region


















Some Matlab code with nested poisson function. Made by Ted Aspiotis

function [poisson,h,modelf] = poisson_distribution(h,modelf)

% seismic code
poisson.h.y_o_p=30;


if isempty(modelf.h.vfva)
    poisson.h.h_warning=warndlg('NO SUCH EVENT IN CHOSEN AREA','ATTENTION');
elseif modelf.h.vfva-1==1
    poisson.h.h_warning=warndlg('ONLY ONE EVENT IN CHOSEN AREA','ATTENTION');
else

    poisson.h.figure = figure;    

poisson.h.menu.hmengps=uimenu('parent',poisson.h.figure,'label','Save data','callback','');
poisson.h.menu.hmengps1=uimenu('parent',poisson.h.menu.hmengps,'label','Ascii');
poisson.h.menu.hmengps2=uimenu('parent',poisson.h.menu.hmengps1,'label','*.txt (recommended)','callback','if ~isempty(poisson.h.probability),
poisson.h.asdf=1;,poisson.h.prompt = {''Name of saving data''};,poisson.h.dlg_title = ''Save Poisson Distribution Seismic Probability data into 
*.txt format '';,poisson.h.num_lines = 1;poisson.h.def = {''''};,poisson.h.answer = inputdlg(poisson.h.prompt,poisson.h.dlg_title,poisson.h.
num_lines,poisson.h.def),nameu = poisson.h.answer{1};,save_datapoisson(poisson,nameu,h,1),else,h_warning_ld1=warndlg
('' b = f(t) data is empty'',''ATTENTION'');,end');
poisson.h.menu.hmengps3=uimenu('parent',poisson.h.menu.hmengps1,'label','*.xls ','callback','if ~isempty(poisson.h.probability),
poisson.h.asdf=2;,poisson.h.prompt = {''Name of saving data''};,poisson.h.dlg_title = ''Save Poisson Distribution Seismic Probability data into
 *.xls format '';,poisson.h.num_lines = 1;poisson.h.def = {''''};,poisson.h.answer = inputdlg(poisson.h.prompt,poisson.h.dlg_title,poisson.h.
num_lines,poisson.h.def),nameu = poisson.h.answer{1};,save_datapoisson(poisson,nameu,h,2),else,h_warning_ld1=warndlg('' b = f(t) 
data is empty'',''ATTENTION'');,end');
poisson.h.menu.hmengps4=uimenu('parent',poisson.h.menu.hmengps1,'label','*.doc ','callback','if ~isempty(poisson.h.probability),
poisson.h.asdf=3;,poisson.h.prompt = {''Name of saving data''};,poisson.h.dlg_title = ''Save Poisson Distribution Seismic Probability data into 
*.doc format '';,poisson.h.num_lines = 1;poisson.h.def = {''''};,poisson.h.answer = inputdlg(poisson.h.prompt,poisson.h.dlg_title,
poisson.h.num_lines,poisson.h.def),nameu = poisson.h.answer{1};,save_datapoisson(poisson,nameu,h,3),else,h_warning_ld1=
warndlg('' b = f(t) data is empty'',''ATTENTION'');,end');




poisson.h.nextearthq=modelf.h.prob(end).year;


poisson.h.vallong1=min(h.main.longitude);
poisson.h.vallong2=max(h.main.longitude);
poisson.h.vallat1=min(h.main.latitude);
poisson.h.vallat2=max(h.main.latitude);

poisson.h.answerforgcf=['EARTHQUAKE PROBABILITY / LONG1>=',num2str(poisson.h.vallong1),'   LONG2<=',num2str(poisson.h.vallong2),'
   LAT1>=',num2str(poisson.h.vallat1),'   LAT2<=',num2str(poisson.h.vallat2),'  MAGNITUDE>=',num2str(h.main.valmagn),'  YEARS:',
num2str(poisson.h.y_o_p),'     tedasjob@gmail.com'];
set(poisson.h.figure,'numbertitle','off','Name',poisson.h.answerforgcf,'Units','normalized',...
    'position',[0.1445 0.1419 0.7352 0.6810])
 poisson.h.hmp=1;











poisson.h.a=[];
poisson.h.aa=[];
poisson.h.a = ones(1,length(modelf.h.prob)-1);
for i=2:length(modelf.h.prob)

    poisson.h.a(i-1)=modelf.h.prob(i).year - modelf.h.prob(i-1).year;
end


poisson.h.suma=sum(poisson.h.a);
poisson.h.tm=poisson.h.suma/length(poisson.h.a);
poisson.h.aa= ones(1,length(poisson.h.a));
for i=1:length(poisson.h.a)
    
    poisson.h.aa(i)=(poisson.h.a(i)-poisson.h.tm)^2;
    
end
poisson.h.sumaa=sum(poisson.h.aa);
poisson.h.s=(((poisson.h.sumaa/(length(poisson.h.a)-1))^((1/2))));   % typikh apoklish
poisson.h.l=1/poisson.h.tm;                                % mesh timh  diakymansh 
%p=(((l*5)^1)*exp(-l*5));               % pithanotita synarthsh katanomhs
                                       % tyxaias metablhths

% posa events exo                                       
poisson.h.lstartx=length(modelf.h.prob) ;
% imeromenia apo to teleytaio event
poisson.h.startx=modelf.h.prob(poisson.h.lstartx).year;
% gia na min apaitei mnimi allazodas kathe fora to size toy matrix
poisson.h.probability = ones(1,400);
poisson.h.xticc = ones(1,400);
for iii=1:400
    % pithanotita gia kathe mia xronia apo tis epomenes toy last event
    poisson.h.probability(iii)=(((poisson.h.l*iii)^1)*exp(-poisson.h.l*iii));
    % gia ton axona x exoyme xronies. px an last event = 1999 to
    % xticc(1)=2000
    poisson.h.xticc(iii)=poisson.h.startx+iii;
end
poisson.h.gcax=axes;
poisson.h.aplot = plot(poisson.h.xticc,poisson.h.probability,'LineWidth',4,'Color',[0 0 0]);
hold on
poisson.h.bplot = bar(poisson.h.xticc,poisson.h.probability);
grid on
ylabel('prpbability   (0~1)')
xlabel('years')
set(poisson.h.gcax,'Color',[.76 .76 .76])

% brisko to megalitero prob kai se poia xronia 
[poisson.h.maxprobvalue poisson.h.positox] = max(poisson.h.probability);
% to idio prama einai to positox kai to terror
poisson.h.terror=abs(poisson.h.xticc(poisson.h.positox)-poisson.h.nextearthq);
poisson.h.textinfo=['PROBABILITY OF FUTURE EARTHQUAKE WITH MAGNITUDE ',num2str(h.main.valmagn),'
+ ML ESTIMATE IN',num2str(poisson.h.xticc(poisson.h.positox))];
poisson.h.title = title(poisson.h.textinfo);
hold on
% trabao mia megali mayri grami ekei poy tha dixnei to red star see stare
% beyond 4 lines
poisson.h.alin=line([poisson.h.xticc(poisson.h.positox) poisson.h.xticc(poisson.h.positox)],[0 max
(poisson.h.probability)+.05],'LineWidth',2,'Color',[0 0 0]);

poisson.h.xticco=poisson.h.xticc(1)-1;
poisson.h.xticcn=poisson.h.xticc(poisson.h.y_o_p);
xlim([poisson.h.xticco poisson.h.xticcn])
% mazi me to alin tha anebainoyn siga siga gia na fanei to peak
poisson.h.stare=text(poisson.h.xticc(poisson.h.positox)-.4,max(poisson.h.probability)+.04,'*');
set(poisson.h.stare,'Color',[1 0 0],'FontSize',55)
xl = get(poisson.h.gcax,'xlim');
xl1 = xl(1)-1;
xlim([xl1 xl(2)])
% ta anaibazo siga siga anabosbinodas kai xroma
for i=1:78
    if mod(i,2)==0
set(poisson.h.stare,'Position',[poisson.h.xticc(poisson.h.positox)-.5,i/200],'Color',[1 0 0])
set(poisson.h.alin,'XData',[poisson.h.xticc(poisson.h.positox) poisson.h.xticc(poisson.h.positox)],'YData',[0 i/200])
    else
        set(poisson.h.stare,'Position',[poisson.h.xticc(poisson.h.positox)-.5,i/200],'Color',[1 1 0])
        set(poisson.h.alin,'XData',[poisson.h.xticc(poisson.h.positox) poisson.h.xticc(poisson.h.positox)],'YData',[0 i/200])
    end
    % kalo einai na pairno os data tin isxy toy epexergasti toy ekastote pc
pause(.01)
end
% en teli ta fiaxno opos prepei na paroysiazodai
poisson.h.alin=line([poisson.h.xticc(poisson.h.positox) poisson.h.xticc(poisson.h.positox)],[0 max(poisson.h.
probability)+.05],'LineWidth',2,'Color',[0 0 0]);

poisson.h.gui.hpan2 = uipanel('Title','History Panel','FontSize',7,...
'BackgroundColor',[.7 .7 .7],...
'Position',[.914 .84 .078 .16]);

 poisson.h.gui.h_text_sdata=uicontrol('Style','text',...
        'units','normalized',...
        'parent',poisson.h.gui.hpan2,'position',[ .1 .68 .8 .2  ],...
        'String','EVENTS',...
        'BackgroundColor',[.7 .7 .7],'ForegroundColor',[0 0 0],...
        'HorizontalAlignment','center');

    % fiaxno ti tha emfanizete sto popup gia na dialego year
clear strin
strin = ones(1,length(modelf.h.prob));
    for i=1:length(modelf.h.prob),strin(i)=modelf.h.prob(i).year;end

    poisson.h.gui.hp_sdata = uicontrol('parent',poisson.h.figure,...
    'Style', 'popup',...
       'String', strin(end:-1:1),...
       'units','normalized',...
       'parent',poisson.h.gui.hpan2,'position',[ .06 .36 .9 .2  ],...
       'Callback',  @(varargin)update_poisson_data);
   % nested function in the end of main poisson function
   
poisson.h.gui.hm_f=uicontrol('Style', 'pushbutton', 'String', 'MAP',...
     'backgroundcolor',[.8 .8 .8],'fontSize',10,...
     'foregroundColor',[0 0 0],...
     'units','normalized',...
     'Position',[ .93 .75 .05 .03  ],'callback','aaxx=axes;,set(aaxx,''Units'',''normalized'',''Position'',[ poisson.h.p
fml  poisson.h.pfmu  poisson.h.pfmw  poisson.h.pfmh]),set(gcf,''CurrentAxes'',aaxx),imgm=image(h.main.s
crsht.cdata);,,xdoaaxx=get(aaxx,''XLim'');,ydoaaxx=get(aaxx,''YLim'');,xdfa1=xdoaaxx(1);,xdfa2=xdoaaxx(2);,
ydfa1=ydoaaxx(1);,ydfa2=ydoaaxx(2);,axis off');
% poy tha orizete kai tha emfanizete o xartis sto apo pano callback
 poisson.h.pfml=.78;
 poisson.h.pfmu=.64;
 poisson.h.pfmw=.1;
 poisson.h.pfmh=.2;
poisson.h.gui.hm_pu=uicontrol('Style', 'pushbutton', 'String', '^',...
     'backgroundcolor',[.8 .8 .8],'fontSize',10,...
     'foregroundColor',[0 0 0],...
     'units','normalized',...
     'Position',[.945 .67 .02 .02 ],'callback',' poisson.h.pfmu= poisson.h.pfmu+.01;,set(aaxx,''Units'',
''normalized'',''Position'',[ poisson.h.pfml  poisson.h.pfmu  poisson.h.pfmw  poisson.h.pfmh])');

 poisson.h.gui.hm_pd=uicontrol('Style', 'pushbutton', 'String', '\/',...
     'backgroundcolor',[.8 .8 .8],'fontSize',10,...
     'foregroundColor',[0 0 0],...
     'units','normalized',...
     'Position',[.945 .628 .02 .02 ],'callback',' poisson.h.pfmu= poisson.h.pfmu-.01;,set(aaxx,''Units'',
''normalized'',''Position'',[ poisson.h.pfml  poisson.h.pfmu  poisson.h.pfmw  poisson.h.pfmh])');

 poisson.h.gui.hm_pl=uicontrol('Style', 'pushbutton', 'String', '<-',...
     'backgroundcolor',[.8 .8 .8],'fontSize',10,...
     'foregroundColor',[0 0 0],...
     'units','normalized',...
     'Position',[.925 .65 .02 .02 ],'callback',' poisson.h.pfml= poisson.h.pfml-.01;,set(aaxx,''Units'',
''normalized'',''Position'',[ poisson.h.pfml  poisson.h.pfmu  poisson.h.pfmw  poisson.h.pfmh])');

 poisson.h.gui.hm_pr=uicontrol('Style', 'pushbutton', 'String', '->',...
     'backgroundcolor',[.8 .8 .8],'fontSize',10,...
     'foregroundColor',[0 0 0],...
     'units','normalized',...
     'Position',[.965 .65 .02 .02 ],'callback',' poisson.h.pfml= poisson.h.pfml+.01;,set(aaxx,''Units'',
''normalized'',''Position'',[ poisson.h.pfml  poisson.h.pfmu  poisson.h.pfmw  poisson.h.pfmh])');

 
 poisson.h.gui.hfad=uicontrol('Style', 'pushbutton', 'String', 'SAVE',...
     'backgroundcolor',[.8 .8 .8],...
      'units','normalized',...
      'Position', [.934 .18 .04 .024],'callback','');

 poisson.h.gui.hxloas=uicontrol('Style', 'pushbutton','String', '->',...
        'backgroundcolor',[.8 .8 .8],...
        'units','normalized',...
        'Position', [.965 .52 .02 .02],...
        'Callback', 'set(gcf,''CurrentAxes'',aaxx),xdfa1=xdfa1+5;,set(aaxx,''XLim'',[xdfa1 xdfa2])');
poisson.h.gui.htfl=uicontrol('Style','text',...
        'backgroundcolor',[.7 .7 .7],...
        'units','normalized',...
        'Position',[.92 .57 .07 .03],...
        'String','AXIS LIMITS');
poisson.h.gui.hxloae=uicontrol('Style', 'pushbutton','String', '<-',...
        'backgroundcolor',[.8 .8 .8],...
        'units','normalized',...
        'Position', [.925 .52 .02 .02],...
        'Callback', 'set(gcf,''CurrentAxes'',aaxx),xdfa2=xdfa2-5;,set(aaxx,''XLim'',[xdfa1 xdfa2])');
    
     poisson.h.gui.hyloas=uicontrol('Style', 'pushbutton','String', '^',...
        'backgroundcolor',[.8 .8 .8],...
        'units','normalized',...
        'Position', [.945 .54 .02 .02 ],...
        'Callback', 'set(gcf,''CurrentAxes'',aaxx),ydfa2=ydfa2-5;,set(aaxx,''yLim'',[ydfa1 ydfa2])');

poisson.h.gui.yxloae=uicontrol('Style', 'pushbutton','String', '\/',...
        'backgroundcolor',[.8 .8 .8],...
        'units','normalized',...
        'Position', [.945 .502 .02 .02],...
        'Callback', 'set(gcf,''CurrentAxes'',aaxx),ydfa1=ydfa1+5;,set(aaxx,''yLim'',[ydfa1 ydfa2])');
    
     poisson.h.gui.hmhap=uicontrol('Style', 'pushbutton', 'String', '+',...
     'backgroundcolor',[.8 .8 .8],'fontSize',10,...
     'foregroundColor',[0 0 0],...
     'units','normalized',...
     'Position',[.934 .4 .02 .02],'callback',' poisson.h.pfmw= poisson.h.pfmw+.01;,set(aaxx,
''Units'',''normalized'',''Position'',[ poisson.h.pfml  poisson.h.pfmu  poisson.h.pfmw  poisson.h.pfmh])');

 
  poisson.h.gui.hmha=uicontrol('Style', 'pushbutton', 'String', '-',...
     'backgroundcolor',[.8 .8 .8],'fontSize',10,...
     'foregroundColor',[0 0 0],...
     'units','normalized',...
     'Position',[.958 .4 .02 .02 ],'callback',' poisson.h.pfmw= poisson.h.pfmw-.01;,set(aaxx,''Units'',''normalized'',
''Position'',[ poisson.h.pfml  poisson.h.pfmu  poisson.h.pfmw  poisson.h.pfmh])');

         poisson.h.gui.hmhax=uicontrol('Style', 'pushbutton', 'String', '+',...
     'backgroundcolor',[.8 .8 .8],'fontSize',10,...
     'foregroundColor',[0 0 0],...
     'units','normalized',...
     'Position',[.934 .36 .02 .02],'callback',' poisson.h.pfmh= poisson.h.pfmh+.01;,set(aaxx,''Units'',
''normalized'',''Position'',[ poisson.h.pfml  poisson.h.pfmu  poisson.h.pfmw  poisson.h.pfmh])');

 
  poisson.h.gui.hmlha=uicontrol('Style', 'pushbutton', 'String', '-',...
     'backgroundcolor',[.8 .8 .8],'fontSize',10,...
     'foregroundColor',[0 0 0],...
     'units','normalized',...
     'Position',[.958 .36 .02 .02 ],'callback',' poisson.h.pfmh= poisson.h.pfmh-.01;,set(aaxx,''Units'',
''normalized'',''Position'',[ poisson.h.pfml  poisson.h.pfmu  poisson.h.pfmw  poisson.h.pfmh])');

poisson.h.gui.htfx=uicontrol('Style','text',...
        'backgroundcolor',[.7 .7 .7],...
        'units','normalized',...
        'Position',[.926 .435 .06 .03],...
        'String','MAP SIZE');
    
    poisson.h.gui.hpan = uipanel('Title','Option Panel','FontSize',7,...
'BackgroundColor',[.7 .7 .7],...
'Position',[.914 .12 .078 .72]);
    

poisson.h.gui.hmpy=uicontrol('Style', 'pushbutton', 'String', '+3',...
     'backgroundcolor',[.8 .8 .8],'fontSize',10,...
     'foregroundColor',[0 0 0],...
     'units','normalized',...
     'Position',[.929 .26 .023 .029],'callback','set(gcf,''CurrentAxes'',poisson.h.gcax),poisson
.h.xticcn=get(poisson.h.gcax,''XLim'');, poisson.h.xticcn=poisson.h.xticcn(2),poisson.h.xticcn
=poisson.h.xticcn+3;,poisson.h.xticco=get(poisson.h.gcax,''XLim'');, poisson.h.xticco=poisson
.h.xticco(1),yopn=poisson.h.xticcn-poisson.h.xticco;,if poisson.h.xticcn>=(poisson.h.xticco+400),
poisson.h.h_warning_ldl=warndlg('' X  AXIS LIMIT MUST BE SMALLER THAN 400 YEARS'',''ATTENTION'');,
poisson.h.xticcn=poisson.h.xticcn-3,else,set(poisson.h.gcax,''xLim'',[poisson.h.xticco poisson.h.xticcn]),end,
answerforgcf=[''EARTHQUAKE PROBABILITY / LONG1>='',num2str(poisson.h.vallong1),''  
 LONG2<='',num2str(poisson.h.vallong2),''   LAT1>='',num2str(poisson.h.vallat1),''   
LAT2<='',num2str(poisson.h.vallat2),''  MAGNITUDE>='',num2str(h.main.valmagn),''  YEARS:'',num2str(yopn),'' 
    tedasjob@gmail.com''];,set(poisson.h.figure,''numbertitle'',''off'',''Name'',answerforgcf)');

 poisson.h.gui.hmmy=uicontrol('Style', 'pushbutton', 'String', '-3',...
     'backgroundcolor',[.8 .8 .8],'fontSize',10,...
     'foregroundColor',[0 0 0],...
     'units','normalized',...
     'Position',[.959 .26 .023 .029],'callback','set(gcf,''CurrentAxes'',poisson.h.gcax),poisson.
h.xticcn=get(poisson.h.gcax,''XLim'');, poisson.h.xticcn=poisson.h.xticcn(2),poisson.h.xticcn
=poisson.h.xticcn-3;,poisson.h.xticco=get(poisson.h.gcax,''XLim'');, poisson.h.xticco=poisson
h.xticco(1),yopn=poisson.h.xticcn-poisson.h.xticco;,if poisson.h.xticcn<=poisson.h.xticco,poisson.
h.h_warning_ldl=warndlg('' X  AXIS LIMIT MUST BE BIGGER'',''ATTENTION'');,xticcn=xticcn+3,
else,set(poisson.h.gcax,''xLim'',[poisson.h.xticco poisson.h.xticcn]),end,answerforgcf=
[''EARTHQUAKE PROBABILITY / LONG1>='',num2str(poisson.h.vallong1),''   LONG2<='',
num2str(poisson.h.vallong2),''   LAT1>='',num2str(poisson.h.vallat1),''   LAT2<='',
num2str(poisson.h.vallat2),''  MAGNITUDE>='',num2str(h.main.valmagn),''  YEARS:'',num2str(yopn),'' 
    tedasjob@gmail.com''];,set(poisson.h.figure,''numbertitle'',''off'',''Name'',answerforgcf)');

 poisson.h.gui.htfpy=uicontrol('Style','text',...
        'backgroundcolor',[.7 .7 .7],...
        'units','normalized',...
        'Position',[.932 .3 .043 .029],...
        'String','YEARS');
    
     poisson.h.gui.htmp=uicontrol('Style','text',...
        'backgroundcolor',[.7 .7 .7],...
        'units','normalized',...
        'Position',[.924 .7 .06 .03],...
        'String','POSITION');


end

% nested function of update data







    function update_poisson_data
        
        % initializing
        poisson.h.a = [];
        poisson.h.aa = [];
        poisson.h.s = [];
        poisson.h.l = [];
        poisson.h.suma = [];
        poisson.h.sumaa = [];
        poisson.h.tm = [];
        poisson.h.probability = [];
        % new variable
        poisson.h.new_year=[];
        
        
        poisson.h.valforpa = get( poisson.h.gui.hp_sdata,'Value');
        % to anebazo kata ena oste an exo 10 event kai eo dialexo to
        % deytero tote na ginei  11-2 = 9 ara na pao sto proteleytaio poy
        % thelo deytero apo to telos
         poisson.h.pairnum=(length(modelf.h.prob)+1)-poisson.h.valforpa;
         if poisson.h.valforpa==length(modelf.h.prob)
            poisson.h.h_warning=warndlg('PROBABILITY MODEL NEEDS 2 OR MORE EVENTS','ATTENTION');
        elseif poisson.h.valforpa==1
            %
            % na fiaxo to proto event gia future
            %
           %poisson.h.h_warning=warndlg('TO ESTIMATE FUTURE POTENTIAL REFER TO
 OPTION WINDOW' ,'ATTENTION! YOU CHOOSE LAST EVENT');
           cla
           get(gca,'title'),set(ans,'str','')
          
           poisson.h.a=[];
poisson.h.aa=[];
poisson.h.a = ones(1,length(modelf.h.prob)-1);
for i=2:length(modelf.h.prob)

    poisson.h.a(i-1)=modelf.h.prob(i).year - modelf.h.prob(i-1).year;
end


poisson.h.suma=sum(poisson.h.a);
poisson.h.tm=poisson.h.suma/length(poisson.h.a);
poisson.h.aa= ones(1,length(poisson.h.a));
for i=1:length(poisson.h.a)
    
    poisson.h.aa(i)=(poisson.h.a(i)-poisson.h.tm)^2;
    
end
poisson.h.sumaa=sum(poisson.h.aa);
poisson.h.s=(((poisson.h.sumaa/(length(poisson.h.a)-1))^((1/2))));   % typikh apoklish
poisson.h.l=1/poisson.h.tm;                                % mesh timh  diakymansh 
%p=(((l*5)^1)*exp(-l*5));               % pithanotita synarthsh katanomhs
                                       % tyxaias metablhths

% posa events exo                                       
poisson.h.lstartx=length(modelf.h.prob) ;
% imeromenia apo to teleytaio event
poisson.h.startx=modelf.h.prob(poisson.h.lstartx).year;
% gia na min apaitei mnimi allazodas kathe fora to size toy matrix
poisson.h.probability = ones(1,400);
poisson.h.xticc = ones(1,400);
for iii=1:400
    % pithanotita gia kathe mia xronia apo tis epomenes toy last event
    poisson.h.probability(iii)=(((poisson.h.l*iii)^1)*exp(-poisson.h.l*iii));
    % gia ton axona x exoyme xronies. px an last event = 1999 to
    % xticc(1)=2000
    poisson.h.xticc(iii)=poisson.h.startx+iii;
end

poisson.h.aplot = plot(poisson.h.xticc,poisson.h.probability,'LineWidth',4,'Color',[0 0 0]);
hold on
poisson.h.bplot = bar(poisson.h.xticc,poisson.h.probability);
grid on
ylabel('prpbability   (0~1)')
xlabel('years')
% brisko to megalitero prob kai se poia xronia 
[poisson.h.maxprobvalue poisson.h.positox] = max(poisson.h.probability);
% to idio prama einai to positox kai to terror
poisson.h.terror=abs(poisson.h.xticc(poisson.h.positox)-poisson.h.nextearthq);
poisson.h.textinfo=['PROBABILITY OF FUTURE EARTHQUAKE WITH MAGNITUDE ',
num2str(h.main.valmagn),'+ ML ESTIMATE IN',num2str(poisson.h.xticc(poisson.h.positox))];
poisson.h.title = title(poisson.h.textinfo);
hold on
% trabao mia megali mayri grami ekei poy tha dixnei to red star see stare
% beyond 4 lines
poisson.h.alin=line([poisson.h.xticc(poisson.h.positox) poisson.h.xticc(poisson.h.positox)],[0 max
(poisson.h.probability)+.05],'LineWidth',2,'Color',[0 0 0]);

poisson.h.xticco=poisson.h.xticc(1)-1;
poisson.h.xticcn=poisson.h.xticc(poisson.h.y_o_p);
xlim([poisson.h.xticco poisson.h.xticcn])
% mazi me to alin tha anebainoyn siga siga gia na fanei to peak
poisson.h.stare=text(poisson.h.xticc(poisson.h.positox)-.4,max(poisson.h.probability)+.04,'*');
set(poisson.h.stare,'Color',[1 0 0],'FontSize',55)
xl = get(poisson.h.gcax,'xlim');
xl1 = xl(1)-1;
xlim([xl1 xl(2)])
% ta anaibazo siga siga anabosbinodas kai xroma
for i=1:78
    if mod(i,2)==0
set(poisson.h.stare,'Position',[poisson.h.xticc(poisson.h.positox)-.5,i/200],'Color',[1 0 0])
set(poisson.h.alin,'XData',[poisson.h.xticc(poisson.h.positox) poisson.h.xticc(poisson.h.positox)],
'YData',[0 i/200])
    else
        set(poisson.h.stare,'Position',[poisson.h.xticc(poisson.h.positox)-.5,i/200],'Color',[1 1 0])
        set(poisson.h.alin,'XData',[poisson.h.xticc(poisson.h.positox) poisson.h.xticc(poisson.h.positox)],
'YData',[0 i/200])
    end
    % kalo einai na pairno os data tin isxy toy epexergasti toy ekastote pc
pause(.01)
end
% en teli ta fiaxno opos prepei na paroysiazodai
poisson.h.alin=line([poisson.h.xticc(poisson.h.positox) poisson.h.xticc(poisson.h.positox)],[0 max
(poisson.h.probability)+.05],'LineWidth',2,'Color',[0 0 0]);

  

        else
        
        for ik=1:(length(modelf.h.prob)-(poisson.h.valforpa-1))
            poisson.h.new_year(ik)=modelf.h.prob(ik).year;
        end
         poisson.h.nextearthq=modelf.h.prob((length(modelf.h.prob)+1)-(poisson.h.valforpa-1)).year;
      
         for i=2:length(poisson.h.new_year)
           poisson.h.a(i-1)=poisson.h.new_year(i)-poisson.h.new_year(i-1);
         end
         poisson.h.suma=sum(poisson.h.a);
         poisson.h.tm=poisson.h.suma/length(poisson.h.a);
         for i=1:length(poisson.h.a)
             poisson.h.aa(i)=( poisson.h.a(i)- poisson.h.tm)^2;
         end
         poisson.h.sumaa=sum(poisson.h.aa);
         poisson.h.s=(((poisson.h.sumaa/(length(poisson.h.a)-1))^((1/2))));   % typikh apoklish
         poisson.h.l=1/poisson.h.tm;                                % mesh timh  diakymansh 
         %p=(((l*5)^1)*exp(-l*5));               % pithanotita synarthsh katanomhs
                                       % tyxaias metablhths

          poisson.h.lstartx=length(poisson.h.new_year) ;
          poisson.h.startx=poisson.h.new_year( poisson.h.lstartx);
         for iii=1:400 
           poisson.h.probability(iii)=((( poisson.h.l*iii)^1)*exp(- poisson.h.l*iii));
           poisson.h.xticc(iii)= poisson.h.startx+iii;
         end
          set(poisson.h.figure,'CurrentAxes',poisson.h.gcax)
          cla
         poisson.h.aplot = plot(poisson.h.xticc,poisson.h.probability,'LineWidth',4,'Color',[0 0 0]);
            hold on
            poisson.h.bplot = bar(poisson.h.xticc,poisson.h.probability);
            grid on
            ylabel('prpbability   (0~1)')
            xlabel('years')
            
[poisson.h.maxprobvalue poisson.h.positox] = max(poisson.h.probability);
% to idio prama einai to positox kai to terror
poisson.h.terror=abs(poisson.h.xticc(poisson.h.positox)-poisson.h.nextearthq);
if poisson.h.xticc(poisson.h.positox)>poisson.h.nextearthq
poisson.h.textinfo=['PROBABILITY OF ',num2str(h.main.valmagn),'+ ML EVENT
 ESTIMATE IN',num2str(poisson.h.xticc(poisson.h.positox)),'       ERROR = -',num2str(poisson.h.terror),' YEARS',' 
   PID:',num2str(poisson.h.pairnum)];
else
 poisson.h.textinfo=['PROBABILITY OF ',num2str(h.main.valmagn),'+ ML EVENT ESTIMATE IN',num2str
(poisson.h.xticc(poisson.h.positox)),'       ERROR = +',num2str(poisson.h.terror),' YEARS',' 
  PID:',num2str(poisson.h.pairnum)];   
end
title(poisson.h.textinfo)
hold on

% trabao mia megali mayri grami ekei poy tha dixnei to red star see stare
% beyond 4 lines
poisson.h.alin=line([poisson.h.nextearthq poisson.h.nextearthq],[0 max(poisson.h.probability)+.05],
'LineWidth',2,'Color',[0 0 0]);

poisson.h.xticco=poisson.h.xticc(1)-1;
poisson.h.xticcn=poisson.h.xticc(poisson.h.y_o_p);
xlim([poisson.h.xticco poisson.h.xticcn])
% new holding up square 
poisson.h.answtn=['EARTHQUAKE IN ',num2str(poisson.h.nextearthq)];
poisson.h.atfe=text(poisson.h.nextearthq-2,max(poisson.h.probability)+.115,poisson.h.answtn,
'EdgeColor','red','LineWidth',2);
poisson.h.antps='PROBABILITY PROCESS';
text(poisson.h.xticc(1)-.4,max(poisson.h.probability)+.07,poisson.h.antps)
poisson.h.ansts=['STARTING IN ',num2str(poisson.h.xticc(1))];
text(poisson.h.xticc(1),max(poisson.h.probability)+.05,poisson.h.ansts)
xl = get(poisson.h.gcax,'xlim');
xl1 = xl(1)-1;
xlim([xl1 xl(2)])
% ta anaibazo siga siga anabosbinodas kai xroma
for i=1:78
set(poisson.h.alin,'XData',[poisson.h.nextearthq poisson.h.nextearthq],'YData',[0 i/200])
set(poisson.h.atfe,'position',[poisson.h.nextearthq-2,(i/200)])
pause(.01)
end
poisson.h.alin=line([poisson.h.nextearthq poisson.h.nextearthq],[0 max(poisson.h.probability)+.1],'LineWidth',2,'Color',[0 0 0]);
set(poisson.h.atfe,'position',[poisson.h.nextearthq-2,max(poisson.h.probability)+.115])
         end
         
         
         
         
    end
    % nested function end

% end poisson function
end