Skip to main content
  • Home
  • Development
  • Documentation
  • Donate
  • Operational login
  • Browse the archive

swh logo
SoftwareHeritage
Software
Heritage
Archive
Features
  • Search

  • Downloads

  • Save code now

  • Add forge now

  • Help

  • ba8c099
  • /
  • tensorly
  • /
  • tenalg
  • /
  • _higher_order_moment.py
Raw File Download

To reference or cite the objects present in the Software Heritage archive, permalinks based on SoftWare Hash IDentifiers (SWHIDs) must be used.
Select below a type of object currently browsed in order to display its associated SWHID and permalink.

  • content
  • directory
content badge
swh:1:cnt:22a12b8181fc5848bfaf9607fbf4dbe7eb1273a5
directory badge
swh:1:dir:516ce30dec932f1afc8fb82197b995a3ed02f149

This interface enables to generate software citations, provided that the root directory of browsed objects contains a citation.cff or codemeta.json file.
Select below a type of object currently browsed in order to generate citations for them.

  • content
  • directory
(requires biblatex-software package)
Generating citation ...
(requires biblatex-software package)
Generating citation ...
_higher_order_moment.py
from ._khatri_rao import khatri_rao

# Author: Jean Kossaifi

# License: BSD 3 clause



def higher_order_moment(matrix, order=3):
    """Higher order moment of a matrix of observations

        Computes the higher moment of order `order` of `matrix`

        Each row of `matrix` represents a samples
        (i.e. an observation)

    Parameters
    ----------
    matrix : 2D-array
        array of shape (n_samples, n_features)

        i.e. each row is a sample
    order : int, optional
        order of the moment to compute
    """
    matrix = matrix - matrix.mean(axis=0)
    n_features = matrix.shape[-1]
    t = khatri_rao([matrix.T] * order).mean(axis=1)
    return t.reshape([n_features] * order)

back to top

Software Heritage — Copyright (C) 2015–2026, The Software Heritage developers. License: GNU AGPLv3+.
The source code of Software Heritage itself is available on our development forge.
The source code files archived by Software Heritage are available under their own copyright and licenses.
Terms of use: Archive access, API— Content policy— Contact— JavaScript license information— Web API