<!DOCTYPE html>
<html>
<head>
<title>統計的方法</title>
<meta charset="UTF-8">
<link rel="stylesheet" href="material.min.css">
<link rel="stylesheet" href="https://storage.googleapis.com/code.getmdl.io/1.0.6/material.indigo-pink.min.css">
<script src="https://storage.googleapis.com/code.getmdl.io/1.0.6/material.min.js"></script>
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
<script src="sample.js"></script>
<script src="jquery.js"></script>
<script src="svgpaint.js"></script>
</head>
<body onload="sample()">
<div class="mdl-layout mdl-js-layout mdl-layout--fixed-header">
<header class="mdl-layout__header">
<div class="mdl-layout__header-row">
<span class="mdl-layout-title">統計的方法</span>
</div>
<div class="mdl-layout__tab-bar mdl-js-ripple-effect">
<a href="#scroll-tab-1" class="mdl-layout__tab is-active">表</a>
<a href="#scroll-tab-2" class="mdl-layout__tab">解答</a>
<a href="#scroll-tab-3" class="mdl-layout__tab">出所</a>
</div>
</header>
<div class="mdl-layout__drawer">
<span class="mdl-layout-title">タイトル</span>
</div>
<main class="mdl-layout__content">
<section class="mdl-layout__tab-panel is-active" id="scroll-tab-1">
<div class="page-content" id="tab2"></div>
</section>
<section class="mdl-layout__tab-panel" id="scroll-tab-2">
<div class="page-content" id="memo"></div>
</section>
<section class="mdl-layout__tab-panel" id="scroll-tab-3">
<div class="page-content">図2-12-1</div>
</section>
</main>
<footer class="mdl-mini-footer">
<div class="mdl-mini-footer__left-section">
<div class="mdl-logo">リンク</div>
<ul class="mdl-mini-footer__link-list">
<li><a href="http://osomatsusan.com/">コード</a></li>
<li><a href="http://osomatsusan.com/">データ</a></li>
</ul>
</div>
</footer>
</div>
</body>
</html>
var point = new Array();
var count = new Array();
function sample(){
for (s = 1; s < 401;s++ ){
p1 = 0;
for(sx=1;sx<6;sx++){
mx = 10*Math.random();
n = Math.floor(mx);
p1=p1+n;
}
point[s]=p1;
}
for (s = 0; s < 51; s++) {
count[s] = 0;
}
for (s = 1; s < 401;s++ ){
sx=point[s];
count[sx]=count[sx]+1;
}
paintx();
paint();
}
function paintx(){
str1="<table class=\"mdl-data-table mdl-js-data-table mdl-data-table--selectable mdl-shadow--2dp\">";
str2="<th class=\"mdl-data-table__cell--non-numeric\">";
str3="<td class=\"mdl-data-table__cell--non-numeric\">";
str=str1;
str=str+"<thead>";
str=str+"<tr>";
str=str+"<th>x</th>";
str=str+"</tr>"
str=str+"</thead>";
str=str+"<tbody>";
for(s=1;s<401;s++){
str=str+"<tr>";
str=str+"<td>"+point[s]+"</td>";
str=str+"</tr>";
}
str=str+"</table>";
$("#tab2").html(str);
}
function paint(){
var sub=new svgpaint();
str="<svg width=\"500\" height=\"500\">";
for(s=0;s<51;s++){
c1 = 10*count[s];
str=str+sub.rect(10*s,500-c1,10,c1,"red");
}
str=str+"</svg>";
$("#memo").html(str);
}
最終更新:2016年03月08日 03:10