The matrix generators for provider Numbers()
See original GitHub issueFeature request
Thesis
The matrix can be useful in working in Jupyter Notebook. So, it would be awesome to support generators of matrix in provider Numbers()
.
I sketched a rough implementation example:
import random
from typing import Tuple, Optional, Union, List
ValuesRange = Union[
List[int],
Tuple[int, int],
]
def matrix(m: int = 3, n: int = 3, values_range: Optional[ValuesRange] = None) -> list:
"""Creates an 𝑚×𝑛 matrix which has 𝑚 rows and 𝑛 columns.
:param m: Rows count.
:param n: Columns count.
:param values_range: Range of values of matrix items.
:return: Matrix 𝑚×𝑛.
"""
if values_range is None:
values_range = (-100, 100)
if len(values_range) > 2:
raise ValueError('Invalid items range! Usage example: items_range=(-10, 10)')
result = [
[random.randint(*values_range) for _ in range(m)]
for _ in range(n)
]
return result
matrix(m=5, n=4, values_range=[-50, 50])
Output:
[[29, 7, 17, -24, -29],
[-26, 13, 29, -25, 6],
[-5, 16, 13, -45, 49],
[23, 20, -25, 14, -25]]
Issue Analytics
- State:
- Created 4 years ago
- Comments:10 (7 by maintainers)
Top Results From Across the Web
Generate Random Matrices - Online Math Tools
World's simplest online utility that generates random matrices. Free, quick, and powerful. Press a button, get a random matrix.
Read more >Generator matrix - Wikipedia
In coding theory, a generator matrix is a matrix whose rows form a basis for a linear code. The codewords are all of...
Read more >Pseudo-Random Numbers - Math.NET Numerics
All random number generators (RNG) generate numbers in a uniform distribution. ... NET Numerics and open the namespaces for random numbers and probability ......
Read more >Generators - ApplicationSet Controller
Matrix generator : The Matrix generator may be used to combine the generated parameters of two separate generators.
Read more >Matrix Generator XLATMR
from the Independent Sets and Generators ; Source: LAPACK ; Discipline: Numerical linear algebra ; Language: Fortran ; Output format: Matrix Market format,...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@anshulxyz Also, a provider
Numbers()
is located here: https://github.com/lk-geimfari/mimesis/blob/master/mimesis/providers/numbers.py@gupta-kartik20 Sure! I’ll wait for PR.