w-distributions
Version:
merge to `w-statistic`
269 lines (76 loc) • 4.48 kB
HTML
<html lang="en">
<head>
<meta charset="utf-8">
<title>Global - Documentation</title>
<script src="scripts/prettify/prettify.js"></script>
<script src="scripts/prettify/lang-css.js"></script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc.css">
<script src="scripts/nav.js" defer></script>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<input type="checkbox" id="nav-trigger" class="nav-trigger" />
<label for="nav-trigger" class="navicon-button x">
<div class="navicon"></div>
</label>
<label for="nav-trigger" class="overlay"></label>
<nav >
<h2><a href="index.html">Home</a></h2><h3>Global</h3><ul><li><a href="global.html#WDistributions">WDistributions</a></li></ul>
</nav>
<div id="main">
<h1 class="page-title">Global</h1>
<section>
<header>
<h2>
</h2>
</header>
<article>
<div class="container-overview">
<dl class="details">
</dl>
</div>
<h3 class="subsection-title">Methods</h3>
<h4 class="name" id="WDistributions"><span class="type-signature"></span>WDistributions<span class="signature">()</span><span class="type-signature"> → {Object}</span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="WDistributions.mjs.html">WDistributions.mjs</a>, <a href="WDistributions.mjs.html#line73">line 73</a>
</li></ul></dd>
</dl>
<div class="description usertext">
<p>計算Uniform、Normal、Binomial、Studentt分佈參數</p>
<p>因原版distributions使用cephes時未用compiled方式來支援瀏覽器, 且cephes內有使用node的Buffer, 需配合node polyfill編譯才能給前端瀏覽器使用</p>
<p>Fork: <a href="https://github.com/AndreasMadsen/distributions">distributions</a></p>
<p>Unit Test: <a href="https://github.com/yuda-lyu/wsemi/blob/master/test/distri.test.js">Github</a></p>
</div>
<h5>Example</h5>
<pre class="prettyprint"><code>//import wd from './src/WDistributions.mjs'
//import wd from './dist/w-distributions.umd.js'
//import wd from 'w-distributions'
async function test() {
let r
let normal = await wd.Normal(1,2) //mean=1,std deviation=2
r = normal.pdf(1)
console.log(r)
// => 0.19947114020071632
r = normal.cdf(1)
console.log(r)
// => 0.5
r = normal.inv(1)
console.log(r)
// => Infiniy
r = normal.mean()
console.log(r)
// => 1
r = normal.median()
console.log(r)
// => 1
r = normal.variance()
console.log(r)
// => 4
//compare with: https://stattrek.com/online-calculator/t-distribution.aspx
let studentt = await wd.Studentt(34) //degrees of freedom=34
r = studentt.inv(0.95) //one or two sided test p-values=0.95
console.log(r)
// => 1.6909242551868549
studentt = await wd.Studentt(4) //degrees of freedom=4
r = studentt.inv(0.05) //one or two sided test p-values=0.05
console.log(r)
// => -2.1318467863266504
}
test()
.catch((err) => {
console.log(err)
})</code></pre>
<h5>Returns:</h5>
<div class="param-desc">
<p>回傳各分佈初始化函數</p>
</div>
<dl class="param-type">
<dt>
Type
</dt>
<dd>
<span class="param-type">Object</span>
</dd>
</dl>
</article>
</section>
</div>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.10</a> on Sun Jun 05 2022 12:04:35 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>
<script>prettyPrint();</script>
<script src="scripts/polyfill.js"></script>
<script src="scripts/linenumber.js"></script>
</body>
</html>