Skip to content

Commit 90537ab

Browse files
committed
Auto-generated commit
1 parent 3f7d2d9 commit 90537ab

File tree

5 files changed

+149
-8
lines changed

5 files changed

+149
-8
lines changed

CHANGELOG.md

+43
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,49 @@
22

33
> Package changelog.
44

5+
<section class="release" id="unreleased">
6+
7+
## Unreleased (2024-09-07)
8+
9+
<section class="packages">
10+
11+
### Packages
12+
13+
</section>
14+
15+
<!-- /.packages -->
16+
17+
<section class="contributors">
18+
19+
### Contributors
20+
21+
A total of 2 people contributed to this release. Thank you to the following contributors:
22+
23+
- Philipp Burckhardt
24+
- Tufail
25+
26+
</section>
27+
28+
<!-- /.contributors -->
29+
30+
<section class="commits">
31+
32+
### Commits
33+
34+
<details>
35+
36+
- [`71af75e`](https://github.com/stdlib-js/stdlib/commit/71af75ec2c9066eb59288ad525ddbf1ad782db0c) - **docs:** improve examples `stats/base/dists/triangular` namespace _(by Tufail, Philipp Burckhardt)_
37+
38+
</details>
39+
40+
</section>
41+
42+
<!-- /.commits -->
43+
44+
</section>
45+
46+
<!-- /.release -->
47+
548
<section class="release" id="v0.3.1">
649

750
## 0.3.1 (2024-08-18)

CONTRIBUTORS

+2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ EuniceSim142 <[email protected]>
2626
Frank Kovacs <[email protected]>
2727
Golden Kumar <[email protected]>
2828
Gunj Joshi <[email protected]>
29+
2930
Harshita Kalani <[email protected]>
3031
Hridyanshu <[email protected]>
3132
Jaimin Godhani <[email protected]>
@@ -96,3 +97,4 @@ nishant-s7 <[email protected]>
9697
orimiles5 <[email protected]>
9798
9899
100+

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -209,8 +209,8 @@ Copyright &copy; 2016-2024. The Stdlib [Authors][stdlib-authors].
209209
[npm-image]: http://img.shields.io/npm/v/@stdlib/stats.svg
210210
[npm-url]: https://npmjs.org/package/@stdlib/stats
211211

212-
[test-image]: https://github.com/stdlib-js/stats/actions/workflows/test.yml/badge.svg?branch=v0.3.1
213-
[test-url]: https://github.com/stdlib-js/stats/actions/workflows/test.yml?query=branch:v0.3.1
212+
[test-image]: https://github.com/stdlib-js/stats/actions/workflows/test.yml/badge.svg?branch=main
213+
[test-url]: https://github.com/stdlib-js/stats/actions/workflows/test.yml?query=branch:main
214214

215215
[coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/stats/main.svg
216216
[coverage-url]: https://codecov.io/github/stdlib-js/stats?branch=main

base/dists/triangular/README.md

+51-4
Original file line numberDiff line numberDiff line change
@@ -107,15 +107,62 @@ y = dist.quantile( 1.9 );
107107

108108
## Examples
109109

110-
<!-- TODO: better examples -->
111-
112110
<!-- eslint no-undef: "error" -->
113111

114112
```javascript
115-
var objectKeys = require( '@stdlib/utils/keys' );
113+
var discreteUniform = require( '@stdlib/random/base/discrete-uniform' );
116114
var triangular = require( '@stdlib/stats/base/dists/triangular' );
117115

118-
console.log( objectKeys( triangular ) );
116+
// Scenario: Modeling completion time for a software development task
117+
118+
// Define the distribution parameters (in hours):
119+
var a = 1.5; // Minimum time (best-case scenario)
120+
var b = 4.5; // Maximum time (worst-case scenario)
121+
var c = discreteUniform( 2, 4 ); // Most likely time (mode)
122+
console.log( 'a: %d, b: %d, c: %d', a, b, c );
123+
124+
// Expected (mean) completion time:
125+
var mean = triangular.mean( a, b, c );
126+
console.log( '\nExpected completion time: %d hours', mean );
127+
128+
// Median completion time:
129+
var median = triangular.median( a, b, c );
130+
console.log( 'Median completion time: %d hours', median );
131+
132+
// Variance in completion time:
133+
var variance = triangular.variance( a, b, c );
134+
console.log( 'Variance in completion time: %d hours^2', variance );
135+
136+
// Probability of completing the task within 3 hours:
137+
var x = 3.0;
138+
var prob = triangular.cdf( x, a, b, c );
139+
console.log( '\nProbability of completing within %d hours: %d', x, prob );
140+
141+
// 90th percentile of completion time:
142+
var p = 0.9;
143+
var percentile = triangular.quantile( p, a, b, c );
144+
console.log( '90% of tasks will be completed within %d hours', percentile );
145+
146+
// Relative likelihood of completing the task in exactly 2.5 hours:
147+
x = 2.5;
148+
var likelihood = triangular.pdf( x, a, b, c );
149+
console.log( '\nRelative likelihood of completing in exactly %d hours: %d', x, likelihood );
150+
151+
// Skewness to understand the distribution's shape:
152+
var skewness = triangular.skewness( a, b, c );
153+
console.log( '\nSkewness of completion times: %d', skewness );
154+
if ( skewness > 0 ) {
155+
console.log( 'The distribution is right-skewed, suggesting occasional longer completion times.' );
156+
} else if ( skewness < 0 ) {
157+
console.log( 'The distribution is left-skewed, suggesting occasional shorter completion times.' );
158+
} else {
159+
console.log( 'The distribution is symmetric.' );
160+
}
161+
162+
// Entropy as a measure of uncertainty in the estimate:
163+
var entropy = triangular.entropy( a, b, c );
164+
console.log( '\nEntropy of the distribution: %d nats', entropy );
165+
console.log( 'Higher entropy indicates more uncertainty in completion times.' );
119166
```
120167

121168
</section>

base/dists/triangular/examples/index.js

+51-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,56 @@
1818

1919
'use strict';
2020

21-
var objectKeys = require( '@stdlib/utils/keys' );
21+
var discreteUniform = require( '@stdlib/random/base/discrete-uniform' );
2222
var triangular = require( './../lib' );
2323

24-
console.log( objectKeys( triangular ) );
24+
// Scenario: Modeling completion time for a software development task
25+
26+
// Define the distribution parameters (in hours):
27+
var a = 1.5; // Minimum time (best-case scenario)
28+
var b = 4.5; // Maximum time (worst-case scenario)
29+
var c = discreteUniform( 2, 4 ); // Most likely time (mode)
30+
console.log( 'a: %d, b: %d, c: %d', a, b, c );
31+
32+
// Expected (mean) completion time:
33+
var mean = triangular.mean( a, b, c );
34+
console.log( '\nExpected completion time: %d hours', mean );
35+
36+
// Median completion time:
37+
var median = triangular.median( a, b, c );
38+
console.log( 'Median completion time: %d hours', median );
39+
40+
// Variance in completion time:
41+
var variance = triangular.variance( a, b, c );
42+
console.log( 'Variance in completion time: %d hours^2', variance );
43+
44+
// Probability of completing the task within 3 hours:
45+
var x = 3.0;
46+
var prob = triangular.cdf( x, a, b, c );
47+
console.log( '\nProbability of completing within %d hours: %d', x, prob );
48+
49+
// 90th percentile of completion time:
50+
var p = 0.9;
51+
var percentile = triangular.quantile( p, a, b, c );
52+
console.log( '90% of tasks will be completed within %d hours', percentile );
53+
54+
// Relative likelihood of completing the task in exactly 2.5 hours:
55+
x = 2.5;
56+
var likelihood = triangular.pdf( x, a, b, c );
57+
console.log( '\nRelative likelihood of completing in exactly %d hours: %d', x, likelihood );
58+
59+
// Skewness to understand the distribution's shape:
60+
var skewness = triangular.skewness( a, b, c );
61+
console.log( '\nSkewness of completion times: %d', skewness );
62+
if ( skewness > 0 ) {
63+
console.log( 'The distribution is right-skewed, suggesting occasional longer completion times.' );
64+
} else if ( skewness < 0 ) {
65+
console.log( 'The distribution is left-skewed, suggesting occasional shorter completion times.' );
66+
} else {
67+
console.log( 'The distribution is symmetric.' );
68+
}
69+
70+
// Entropy as a measure of uncertainty in the estimate:
71+
var entropy = triangular.entropy( a, b, c );
72+
console.log( '\nEntropy of the distribution: %d nats', entropy );
73+
console.log( 'Higher entropy indicates more uncertainty in completion times.' );

0 commit comments

Comments
 (0)