アットウィキロゴ

lda766

var v=new Array();
var th=new Array();
var ths=new Array();
var paper=new Array();
var ps=new Array();
var sig=new Array();
 
function sample(){
 
    for(s=1;s<7;s++){
    v[s]=new Array();    
    }
 
    for(s=1;s<7;s++){
    for(sx=1;sx<7;sx++){
    v[s][sx]=0;    
    }
    }
 
v[1][1]=1;
v[1][5]=1;
v[2][2]=1;
v[2][5]=1;
v[3][1]=1;
v[3][2]=1;
 
v[4][4]=1;
v[4][3]=1;
v[5][3]=1;
v[5][6]=1;
v[6][4]=1;
v[6][6]=1;
 
for(s=1;s<3;s++){
th[s]=new Array();    
} 
 
 for(s=1;s<3;s++){
 for(sx=1;sx<7;sx++){
 th[s][sx]=Math.random();    
 }
 } 
 
for(s=1;s<7;s++){
paper[s]=new Array();    
} 
 
for(s=1;s<7;s++){
ps[s]=new Array();    
} 
 
for(s=1;s<3;s++){
ths[s]=new Array();    
} 
 
 for(s=1;s<7;s++){
 paper[s][1]=Math.random();    
 paper[s][2]=1-paper[s][1];
 } 
 
 
for(de=1;de<51;de++){
 
 
for(s=1;s<7;s++){
p1=paper[s][1];
for(sx=1;sx<7;sx++){
if(v[s][sx]==1)p1=p1*th[1][sx];        
if(v[s][sx]==1)p1=p1*0.01;   
}    
p2=paper[s][2];
for(sx=1;sx<7;sx++){
if(v[s][sx]==1)p2=p2*th[2][sx];        
if(v[s][sx]==1)p2=p2*0.01;   
}    
ps[s][1]=p1/(p1+p2);
ps[s][2]=p2/(p1+p2);
}
 
 
for(s=1;s<3;s++){
sig[s]=new Array();    
} 
 
 
for(s=1;s<3;s++){
for(sx=1;sx<7;sx++){
c1=0;
c2=0;
for(tx=1;tx<7;tx++){
if(v[tx][sx]==1)c1=c1+1;    
if(v[tx][sx]==1)c2=c2+paper[tx][s];  
}
sig[s][sx]=c2/c1;
}   
}
 
var w=new Array();
 
for(s=1;s<7;s++){
c1=0;
c2=0;
for(sx=1;sx<7;sx++){        
c2=c2+1;
if(v[sx][s]==1)c1=c1+1;
}
w[s]=c1/c2;
}
 
var top=new Array();
 
for(s=1;s<3;s++){
c1=0;
c2=0;
for(sx=1;sx<7;sx++){        
c2=c2+1;
c1=c1+paper[sx][s];
}
top[s]=c1/c2;
}
 
 
for(s=1;s<3;s++){
for(sx=1;sx<7;sx++){ 
ths[s][sx]=sig[s][sx]*w[sx]/top[s];    
}
}
 
 
for(s=1;s<7;s++){
for(sx=1;sx<3;sx++){ 
paper[s][sx]=ps[s][sx];    
}
}
 
for(s=1;s<3;s++){
for(sx=1;sx<7;sx++){ 
th[s][sx]=ths[s][sx];    
}
}
 
}
 
 
paint();
 
paintx();    
 
 
}
 
function paint(){
 
 
 
   str="<table>";
   str=str+"<tr>";
    str=str+"<th>文章番号</th>";
   str=str+"<th>トピック1</th>";
   str=str+"<th>トピック2</th>";
    str=str+"</tr>"
   for(s=1;s<7;s++){
   str=str+"<tr>";
   str=str+"<td>"+s+"</td>";
   str=str+"<td>"+paper[s][1]+"</td>";
   str=str+"<td>"+paper[s][2]+"</td>";
   str=str+"</tr>";
   }
str=str+"</table>";
 
 
 
 $("#memo").html(str);
 
 
 
    }
 
 
function paintx(){
 
 
 
   str="<table>";
   str=str+"<tr>";
    str=str+"<th>単語番号</th>";
   str=str+"<th>トピック1</th>";
   str=str+"<th>トピック2</th>";
    str=str+"</tr>"
   for(s=1;s<7;s++){
   str=str+"<tr>";
   str=str+"<td>"+s+"</td>";
   str=str+"<td>"+th[1][s]+"</td>";
   str=str+"<td>"+th[2][s]+"</td>";
   str=str+"</tr>";
   }
str=str+"</table>";
 
 
 
 $("#memox").html(str);
 
 
 
    }
 
最終更新:2016年05月12日 13:19