Bug 154872 - Missing distributions in Calc's Random Number Generator
Summary: Missing distributions in Calc's Random Number Generator
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
Inherited From OOo
Hardware: All All
: medium enhancement
Assignee: Not Assigned
URL:
Whiteboard: target:7.6.0 inReleaseNotes:7.6 targe...
Keywords:
Depends on:
Blocks: Calc-Enhancements
  Show dependency treegraph
 
Reported: 2023-04-17 21:27 UTC by Rafael Lima
Modified: 2023-09-10 21:10 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments
Comparison between Calc and Excel RNG's (87.97 KB, application/vnd.oasis.opendocument.graphics)
2023-04-17 21:27 UTC, Rafael Lima
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Rafael Lima 2023-04-17 21:27:43 UTC
Created attachment 186746 [details]
Comparison between Calc and Excel RNG's

Calc has a good Random Number Generator (RNG), however it lacks 3 options that are offered by Excel's RNG:

1) Poisson distribution
2) Patterned
3) Discrete distribution (a.k.a custom distribution)

Distributions (1) and (3) are very relevant in universitites when teaching Discrete Simulation and Stochastic processes.

So I would like to propose the implementation of these distributions to make Calc a better choice to teach these subjects.

See attached screenshots comparing the features offered by Calc and Excel.
Comment 1 Stéphane Guillou (stragu) 2023-05-03 08:17:24 UTC
I agree that we need to cover extra distributions.

Regarding (3), the name "Discrete" is quite generic and can be a category of distributions. Wondering if there is a better name for it.
https://en.wikipedia.org/wiki/Probability_distribution#Discrete_probability_distribution

I couldn't find detailed info from MS Office, but here's a overview of the options: https://officetuts.net/excel/examples/random-number-generator/
Comment 3 Bartosz 2023-05-05 22:24:45 UTC
The instruction how to generate numbers with specific distribution with MS Excel is available at:
https://www.youtube.com/watch?v=BWitZ9q2kuU
Comment 4 Bartosz 2023-05-05 22:36:11 UTC
I have created Review for Poisson distribution:
https://gerrit.libreoffice.org/c/core/+/151439
Comment 5 Commit Notification 2023-05-06 01:54:48 UTC
Bartosz Kosiorek committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/793cc7d2ef5967af90a6810e597e1e12bd42777c

tdf#154872 Add Poisson distribution to Random Number Generators

It will be available in 7.6.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 6 Rafael Lima 2023-05-07 13:49:05 UTC
(In reply to Commit Notification from comment #5)
> Bartosz Kosiorek committed a patch related to this issue.
> It has been pushed to "master":

Thank you for the Poisson patch. I've just tested it and it works nicely!

Tested with

Version: 7.6.0.0.alpha0+ (X86_64) / LibreOffice Community
Build ID: 6f67eb36d035fa3fe4103e497207452602ff993b
CPU threads: 16; OS: Linux 6.2; UI render: default; VCL: kf5 (cairo+xcb)
Locale: pt-BR (pt_BR.UTF-8); UI: en-US
Calc: CL threaded

As for the other two distributions, I would say that the "Patterned" one is not commonly used, so we should not need to worry about it. TBH I could hardly find information about how it is supposed to work.

OTOH, the "Discrete" distribution is more relevant and commonly used in discrete simulation lectures. I'm not sure if you're planning to implement it as well, but in case you do, here's a video explaining how it works in Excel:

https://www.youtube.com/watch?v=emtaBhH7kf0
Comment 7 Bartosz 2023-05-08 07:03:32 UTC
The "Discrete" distribution is more complex to implement (it needs additional UI changes).
Fortunately the existing STD implementation is available here:
https://en.cppreference.com/w/cpp/numeric/random/discrete_distribution
Comment 8 Stéphane Guillou (stragu) 2023-05-09 09:22:35 UTC
Poisson is in the release notes: https://wiki.documentfoundation.org/index.php?title=ReleaseNotes%2F7.6&type=revision&diff=668788&oldid=668205
Comment 9 Bartosz 2023-05-10 18:00:16 UTC
For now let's close it. The Poisson distribution was added to LO.
Comment 10 Commit Notification 2023-09-10 21:10:51 UTC
Bartosz Kosiorek committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/help/commit/bb07bc0599affc52cebc346ddc330fb61b496462

tdf#154872 Add Poisson distribution entry to documentation