Skip to content

Conversation

@forfudan
Copy link
Collaborator

@forfudan forfudan commented Jan 28, 2025

This PR makes some updates to the statistics module:

  1. Add returned_dtype to several functions (mean, median) which defaults to f64.
  2. Add an overload of mean that calculates the average of all items and returns a scalar. Remove the function cummean.
  3. Add variance and std functions. Remove cumpvariance and cumpstd functions (the formulae are not correct).
  4. Incorporate the changes into the corresponding NDArray. Add variance and std methods.
  5. Fix the current tests and add tests for statistics module.
  6. Add more detailed docstring for functions.

@forfudan forfudan marked this pull request as draft January 28, 2025 16:28
commit 539af95
Author: ZHU Yuhao 朱宇浩 <[email protected]>
Date:   Tue Jan 28 22:14:28 2025 +0100

    [routine][random] Update the random module + unify behaviors + add `randint` (Mojo-Numerics-and-Algorithms-group#199)

    The `random` module was created at quite an early stage. A lot of things
    should be re-considered. This PR aims to refactor the random module by:

    1. Aligning the functional behaviors as much as possible with `numpy`
    while keeping internal consistency of style: The `shape` always comes as
    the first argument.
    2. For all functions, accept `shape` as an `NDArrayShape`. Meanwhile, we
    still provide overloads for `*shape: Int`. (`shape: List[Int]` is also
    possible but not recommened).
    3. `rand` now generates uniformed distributed values and does not accept
    integral types.
    4. `randint` is added to generate random integral values based on `low`
    and `high`. add tests for it.
    5. `random_exponential` is renamed as `exponential` (same as
    numpy)[https://numpy.org/doc/stable/reference/random/generated/numpy.random.exponential.html#numpy.random.exponential].
@forfudan forfudan marked this pull request as ready for review January 28, 2025 23:10
@MadAlex1997 MadAlex1997 merged commit 75fb2a5 into Mojo-Numerics-and-Algorithms-group:pre-0.6 Jan 29, 2025
2 checks passed
@forfudan forfudan deleted the update branch January 29, 2025 08:50
forfudan added a commit to forfudan/NuMojo that referenced this pull request Jan 30, 2025
…dtype` + unify functions (Mojo-Numerics-and-Algorithms-group#200)

This PR makes some updates to the `statistics` module:

1. Add `returned_dtype` to several functions (`mean`, `median`) which
defaults to `f64`.
2. Add an overload of `mean` that calculates the average of all items
and returns a scalar. Remove the function `cummean`.
3. Add `variance` and `std` functions. Remove `cumpvariance` and
`cumpstd` functions (the formulae are not correct).
4. Incorporate the changes into the corresponding `NDArray`. Add
`variance` and `std` methods.
5. Fix the current tests and add tests for statistics module.
6. Add more detailed docstring for functions.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants