Repository: geomstats/geomstats

Issue:
SpecialEuclieanMatrixLieAlgebra randompoint has doesn't generate valid point
```
from geomstats.geometry.special_euclidean import SpecialEuclideanMatrixLieAlgebra 
algebra  = SpecialEuclideanMatrixLieAlgebra(2)
point = algebra.random_point(2) 
algebra.belongs(point)
```

Discussion:
codecov[bot]: # [Codecov](https://codecov.io/gh/geomstats/geomstats/pull/1411?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=geomstats) Report
> Merging [#1411](https://codecov.io/gh/geomstats/geomstats/pull/1411?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=geomstats) (0e6f594) into [master](https://codecov.io/gh/geomstats/geomstats/commit/d6031af2dc487c1c5e82dc0421d856977c70ed4a?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=geomstats) (d6031af) will **decrease** coverage by `9.32%`.
> The diff coverage is `100.00%`.

[![Impacted file tree graph](https://codecov.io/gh/geomstats/geomstats/pull/1411/graphs/tree.svg?width=650&height=150&src=pr&token=k9LBewrKqJ&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=geomstats)](https://codecov.io/gh/geomstats/geomstats/pull/1411?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=geomstats)

```diff
@@            Coverage Diff             @@
##           master    #1411      +/-   ##
==========================================
- Coverage   93.52%   84.20%   -9.31%     
==========================================
  Files          98       84      -14     
  Lines       10187     9147    -1040     
==========================================
- Hits         9526     7701    -1825     
- Misses        661     1446     +785     
```

| Flag | Coverage Δ | |
|---|---|---|
| autograd | `?` | |
| numpy | `?` | |
| pytorch | `84.20% <100.00%> (+0.01%)` | :arrow_up: |
| tensorflow | `?` | |

Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=geomstats#carryforward-flags-in-the-pull-request-comment) to find out more.

| [Impacted Files](https://codecov.io/gh/geomstats/geomstats/pull/1411?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=geomstats) | Coverage Δ | |
|---|---|---|
| [geomstats/geometry/special\_euclidean.py](https://codecov.io/gh/geomstats/geomstats/pull/1411/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=geomstats#diff-Z2VvbXN0YXRzL2dlb21ldHJ5L3NwZWNpYWxfZXVjbGlkZWFuLnB5) | `79.91% <100.00%> (-10.44%)` | :arrow_down: |
| [geomstats/learning/pca.py](https://codecov.io/gh/geomstats/geomstats/pull/1411/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=geomstats#diff-Z2VvbXN0YXRzL2xlYXJuaW5nL3BjYS5weQ==) | `14.64% <0.00%> (-79.67%)` | :arrow_down: |
| [geomstats/datasets/prepare\_emg\_data.py](https://codecov.io/gh/geomstats/geomstats/pull/1411/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=geomstats#diff-Z2VvbXN0YXRzL2RhdGFzZXRzL3ByZXBhcmVfZW1nX2RhdGEucHk=) | `22.86% <0.00%> (-77.14%)` | :arrow_down: |
| [geomstats/learning/online\_kmeans.py](https://codecov.io/gh/geomstats/geomstats/pull/1411/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=geomstats#diff-Z2VvbXN0YXRzL2xlYXJuaW5nL29ubGluZV9rbWVhbnMucHk=) | `18.61% <0.00%> (-76.74%)` | :arrow_down: |
| [.../learning/agglomerative\_hierarchical\_clustering.py](https://codecov.io/gh/geomstats/geomstats/pull/1411/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=geomstats#diff-Z2VvbXN0YXRzL2xlYXJuaW5nL2FnZ2xvbWVyYXRpdmVfaGllcmFyY2hpY2FsX2NsdXN0ZXJpbmcucHk=) | `28.58% <0.00%> (-71.42%)` | :arrow_down: |
| [geomstats/learning/kmeans.py](https://codecov.io/gh/geomstats/geomstats/pull/1411/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=geomstats#diff-Z2VvbXN0YXRzL2xlYXJuaW5nL2ttZWFucy5weQ==) | `17.86% <0.00%> (-69.64%)` | :arrow_down: |
| [geomstats/information\_geometry/dirichlet.py](https://codecov.io/gh/geomstats/geomstats/pull/1411/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=geomstats#diff-Z2VvbXN0YXRzL2luZm9ybWF0aW9uX2dlb21ldHJ5L2RpcmljaGxldC5weQ==) | `36.34% <0.00%> (-59.35%)` | :arrow_down: |
| [geomstats/learning/exponential\_barycenter.py](https://codecov.io/gh/geomstats/geomstats/pull/1411/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=geomstats#diff-Z2VvbXN0YXRzL2xlYXJuaW5nL2V4cG9uZW50aWFsX2JhcnljZW50ZXIucHk=) | `49.02% <0.00%> (-50.98%)` | :arrow_down: |
| [geomstats/learning/expectation\_maximization.py](https://codecov.io/gh/geomstats/geomstats/pull/1411/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=geomstats#diff-Z2VvbXN0YXRzL2xlYXJuaW5nL2V4cGVjdGF0aW9uX21heGltaXphdGlvbi5weQ==) | `42.23% <0.00%> (-45.55%)` | :arrow_down: |
| [geomstats/learning/\_template.py](https://codecov.io/gh/geomstats/geomstats/pull/1411/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=geomstats#diff-Z2VvbXN0YXRzL2xlYXJuaW5nL190ZW1wbGF0ZS5weQ==) | `58.14% <0.00%> (-41.86%)` | :arrow_down: |
| ... and [38 more](https://codecov.io/gh/geomstats/geomstats/pull/1411/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=geomstats) | |

------

[Continue to review full report at Codecov](https://codecov.io/gh/geomstats/geomstats/pull/1411?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=geomstats).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=geomstats)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/geomstats/geomstats/pull/1411?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=geomstats). Last update [d60d543...0e6f594](https://codecov.io/gh/geomstats/geomstats/pull/1411?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=geomstats). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=geomstats).


Patch:
diff --git a/geomstats/geometry/special_euclidean.py b/geomstats/geometry/special_euclidean.py
index 2090419f1..32a15efca 100644
--- a/geomstats/geometry/special_euclidean.py
+++ b/geomstats/geometry/special_euclidean.py
@@ -1307,9 +1307,10 @@ class SpecialEuclideanMatrixLieAlgebra(MatrixLieAlgebra):
 
     def __init__(self, n):
         dim = int(n * (n + 1) / 2)
-        super(SpecialEuclideanMatrixLieAlgebra, self).__init__(dim, n)
+        super(SpecialEuclideanMatrixLieAlgebra, self).__init__(dim, n + 1)
 
         self.skew = SkewSymmetricMatrices(n)
+        self.n = n
 
     def _create_basis(self):
         """Create the canonical basis."""
@@ -1356,6 +1357,28 @@ class SpecialEuclideanMatrixLieAlgebra(MatrixLieAlgebra):
         belongs = gs.logical_and(belongs, all_zeros)
         return belongs
 
+    def random_point(self, n_samples=1, bound=1.0):
+        """Sample in the lie algebra with a uniform distribution in a box.
+
+        Parameters
+        ----------
+        n_samples : int
+            Number of samples.
+            Optional, default: 1.
+        bound : float
+            Side of hypercube support of the uniform distribution.
+            Optional, default: 1.0
+
+        Returns
+        -------
+        point : array-like, shape=[..., n + 1, n + 1]
+           Sample.
+        """
+        point = super(SpecialEuclideanMatrixLieAlgebra, self).random_point(
+            n_samples, bound
+        )
+        return self.projection(point)
+
     def projection(self, mat):
         """Project a matrix to the Lie Algebra.
 


Test patch:
diff --git a/tests/tests_geomstats/test_special_euclidean.py b/tests/tests_geomstats/test_special_euclidean.py
index 6c56a44b7..7361f960b 100644
--- a/tests/tests_geomstats/test_special_euclidean.py
+++ b/tests/tests_geomstats/test_special_euclidean.py
@@ -205,6 +205,12 @@ class TestSpecialEuclidean(geomstats.tests.TestCase):
             algebra = SpecialEuclideanMatrixLieAlgebra(n)
             self.assertEqual(int(n * (n + 1) / 2), algebra.dim)
 
+    def test_random_and_belongs_lie_algerba(self):
+        algebra = self.group.lie_algebra
+        point = algebra.random_point(2)
+        results = algebra.belongs(point)
+        self.assertTrue(gs.all(results))
+
     def test_belongs_lie_algebra(self):
         theta = gs.pi / 3
         vec_1 = gs.array([[0.0, -theta, 2.0], [theta, 0.0, 3.0], [0.0, 0.0, 0.0]])