stdlib-js / stdlib-js/stdlib

[BUG]: quantile function of Beta distribution fails in production build with Next.js

Open
#3,011 8 comments 0 reactions 0 assignees View on GitHub
Bug Needs Discussion Statistics
Dominant language
JavaScript
Stars
6k
Forks
1.3k
Avg merge
1d 3h
Merged PRs (30d)
611

Description

### Description

I have an application written in Next.js and some code that uses `beta` distribution from `'@stdlib/stats-base-dists/dist'`. I noticed that the `quantile` function is completely broken while building the application in production mode (`next build && next start`). For example the output in Chrome console:
```js
> dist = new window.beta_test.Beta(5, 5) // I did an ugly hack window.beta_test = beta in the code
w {}
> dist.quantile(0.1)
0.9999999996744877
> dist.quantile(0.5)
4.6663115970492885e-302
```

The quantile function works as expected if I run the application in the development mode (`next dev`)
```js
> dist = new window.beta_test.Beta(5, 5)
t {}
> dist.quantile(0.1)
0.30096876359321467
> dist.quantile(0.5)
0.5
```
I'm not sure if this is the case with other distributions

### Related Issues

Related issues # , # , and # .

### Questions

No.

### Demo

_No response_

### Reproduction

- a
- b
- c

### Expected Results

_No response_

### Actual Results

_No response_

### Version

0.2.2

### Environments

Chrome

### Browser Version

129.0.6668.91

### Node.js / npm Version

_No response_

### Platform

MacOS

### Checklist

- [x] Read and understood the [Code of Conduct](https://github.com/stdlib-js/stdlib/blob/develop/CODE_OF_CONDUCT.md).
- [x] Searched for existing issues and pull requests.

Contributor guide

Open the contributing guide

Research direction

Start with the @stdlib/stats-base-dists/dist Beta entry point and reproduce the reported quantile calls under next dev versus next build && next start. Trace the production bundle behavior around Beta.quantile and compare it with development behavior. Done means quantile returns the expected values in a production Next.js build, with regression coverage if the relevant test location is identified.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, next.js
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.