801 - 850 Flashcards

1
Q

set.issubset()

A

позволяет проверить находится ли каждый элемент множества sets в последовательности other. Метод возвращает True, если множество sets является подмножеством итерируемого объекта other, если нет, то вернет False.

x = {"a", "b", "c"}
y = {"f", "e", "d", "c", "b", "a"}
z = x.issubset(y)

print(z)
👉 True
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

set.difference_update()

A

method removes the items that exist in both sets.

x = {"apple", "banana", "cherry"}
y = {"google", "microsoft", "apple"}
x.difference_update(y)

print(x)
👉 {'cherry', 'banana'}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

set.difference()

A

method returns a set that contains the difference between two sets.Meaning: The returned set contains items that exist only in the first set, and not in both sets.

x = {"apple", "banana", "cherry"}
y = {"google", "microsoft", "apple"}
z = x.difference(y) 
print(z)

👉 {'banana', 'cherry'}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

set.add()

A

one item to a set use the add() method.

thisset = {"apple", "banana", "cherry"}
thisset.add("orange")
print(thisset)

👉 {'apple', 'cherry', 'banana', 'orange'}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

list.extend()

A

method adds the specified list elements (or any iterable) to the end of the current list.

fruits = ['apple', 'banana', 'cherry']
cars = ['Ford', 'BMW', 'Volvo']
fruits.extend(cars)

print(fruits)
👉 ['apple', 'banana', 'cherry', 'Ford', 'BMW', 'Volvo']
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

list.sorted(iterable, *, key=None, reverse=False)

🎯 iterable - объект, поддерживающий итерирование
🎯 key=None - пользовательская функция, которая применяется к каждому элементу последовательности
🎯 reverse=False - порядок сортировки

A

function returns a sorted list of the specified iterable object. You can specify ascending or descending order. Strings are sorted alphabetically, and numbers are sorted numerically.

line = 'This is a test string from Andrew'
x = sorted(line.split(), key=str.lower)

print(x)
👉 ['a', 'Andrew', 'from', 'is', 'string', 'test', 'This']
student = [('john', 'A', 15), ('jane', 'B', 12), ('dave', 'B', 10)]
x = sorted(student, key=lambda student: student[2])

print(x)
👉 [('dave', 'B', 10), ('jane', 'B', 12), ('john', 'A', 15)]
data = [('red', 1), ('blue', 1), ('red', 2), ('blue', 2)]
x = sorted(data, key=lambda data: data[0])

print(x)
👉 [('blue', 1), ('blue', 2), ('red', 1), ('red', 2)]
a = ("b", "g", "a", "d", "f", "c", "h", "e")
x = sorted(a)

print(x)
👉 ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h']
a = (1, 11, 2)
x = sorted(a)

print(x)
👉 [1, 2, 11]
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

list.reverse()

A

method reverses the sorting order of the elements. поменять местами список

fruits = ['apple', 'banana', 'cherry']
fruits.reverse()

print(fruits)
👉 ['cherry', 'banana', 'apple']
areas = ["hallway", 11.25, "kitchen", 18.0, "living room", 20.0, "bedroom", 10.75, "bathroom", 9.50]

upstairs = areas[:-5:-1]
upstairs_2 = areas[-4:]

print(upstairs)
👉 [9.5, 'bathroom', 10.75, 'bedroom']

print(upstairs_2)
👉 ['bedroom', 10.75, 'bathroom', 9.5]
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

list.sort()

A

method that will sort the list alphanumerically, ascending, by default.

thislist = ["orange", "mango", "kiwi", "pineapple", "banana"]
thislist.sort()
print(thislist)

👉 ['banana', 'kiwi', 'mango', 'orange', 'pineapple']
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

list.remove()

A

method removes the specified item.

thislist = ["apple", "banana", "cherry"]
thislist.remove("banana")
print(thislist)

👉 ['apple', 'cherry']
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

list.insert()

A

вставить method inserts the specified value at the specified position.

fruits = ['apple', 'banana', 'cherry']
fruits.insert(1, "orange")
print(fruits)

👉 ['apple', 'orange', 'banana', 'cherry']
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

list.len()

A

function returns the number of items in an object.

mylist = ["apple", "orange", "cherry"]
x = len(mylist)
print(x)
👉 3
x = len("Hello")
print(x)
👉 5
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

list.pop()

A

method removes the element at the specified position.

fruits = ['apple', 'banana', 'cherry']
fruits.pop(1)

print(fruits)
👉 ['apple', 'cherry']
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

list.index()

A

method returns the position at the first occurrence of the specified value.

fruits = ['apple', 'banana', 'cherry']
x = fruits.index("cherry")

print(x)
👉 2
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

list.count()

A

method returns the number of elements with the specified value.

fruits = ["apple", "banana", "cherry", "cherry"]
x = fruits.count("cherry")

print(x)
👉 2
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

list.clear()

A

method removes all the elements from a list.

fruits = ["apple", "banana", "cherry"]
fruits.clear()
print(fruits)

👉 []
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

list.append()

A

method appends an element to the end of the list.

fruits = ["apple", "banana", "cherry"]
fruits.append("orange")
print(fruits)

👉 ['apple', 'banana', 'cherry', 'orange']
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

exec(object, globals=None, locals=None)

🎯 object - строка кода, либо объект кода
🎯 globals - словарь глобального пространства, относительно которого следует исполнить код
🎯 locals - объект-отображение (например dict), локальное пространство, в котором следует исполнить код.

A

поддерживает динамическое выполнение кода Python и принимает большие блоки кода, в отличие от eval(). Передаваемый функции код должен быть либо строкой, либо объектом кода, например сгенерированный функцией compile(). Если это строка, строка анализируется как набор операторов Python, который затем выполняется.

x = 'name = "John"\nprint(name)'

exec(x)
👉 John
y = 'print("5 + 10 =", (5+10))'
exec(y)

👉 5 + 10 = 15
prog = 'for x in range(9):\n    res = x*x\n    print(res)'
exec(prog)
👉 0
👉 1
👉 4
👉 9
👉 16
👉 25
👉 36
👉 49
👉 64
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

dict.values()

dict.values

A

method returns a view object. The view object contains the values of the dictionary, as a list.

car = {
  "brand": "Ford",
  "model": "Mustang",
  "year": 1964
}
x = car.values()

print(x)
👉 dict_values(['Ford', 'Mustang', 1964])
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

dict.update()

A

method inserts the specified items to the dictionary.

car = {
  "brand": "Ford",
  "model": "Mustang",
  "year": 1964
}
car.update({"color": "White"})
print(car)

👉 {'brand': 'Ford', 'model': 'Mustang', 'year': 1964, 'color': 'White'}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

dict.keys()

A

method returns a view object. The view object contains the keys of the dictionary, as a list.

car = {
  "brand": "Ford",
  "model": "Mustang",
  "year": 1964
}
x = car.keys()

print(x)
👉 dict_keys(['brand', 'model', 'year'])
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

dict.items()

A

возвращает список кортежей вида (key, value), состоящий из элементов словаря.

car = {
  "brand": "Ford",
  "model": "Mustang",
  "year": 1964
}
x = car.items()
print(x)

👉 dict_items([('brand', 'Ford'), ('model', 'Mustang'), ('year', 1964)])
22
Q

dict.get()

A

method returns the value of the item with the specified key. получить елемент со словаря.

car = {
  "brand": "Ford",
  "model": "Mustang",
  "year": 1964
}
x = car.get("model")

print(x)
👉 Mustang
23
Q

dict.fromkeys(iterable[, value])

A

метод класса, который возвращает новый словарь, значение по умолчанию None или заданное значение.
~~~
x = (‘key1’, ‘key2’, ‘key3’)
y = 0
thisdict = dict.fromkeys(x, y)

print(thisdict)
👉 [‘key1’: 0, ‘key2’: 0, ‘key3’: 0]
~~~

x = dict.fromkeys(['one', 'two', 'three', 'four'])
print(x)
👉 {'one': None, 'two': None, 'three': None, 'four': None}

x = dict.fromkeys(['one', 'two', 'three', 'four'], 0)
print(x)
👉 {'one': 0, 'two': 0, 'three': 0, 'four': 0}
24
Q

numpy.array(object, dtype=None, *, copy=True, order=’K’, subok=False, ndmin=0, like=None)

🎯 dtype — The desired data-type for the array.
🎯 copy — If true (default), then the object is copied.
🎯 order — Specify the memory layout of the array.
🎯 ndminint — Specifies the minimum number of dimensions that the resulting array should have.
🎯 subokbool — If True, then sub-classes will be passed-through, otherwise the returned array will be forced to be a base-class array (default).

A

создает array.

np.array([[1, 2], [3, 4]])

👉 array([[1, 2],
          [3, 4]])
a = np.array([[1,2,3,4,5,6,7],[8,9,10,11,12,13,14]])

print(a[1, 5])
👉 13
a = np.array([[1,2,3,4,5,6,7],[8,9,10,11,12,13,14]])

print(a[0, :])
👉 array([1, 2, 3, 4, 5, 6, 7])
a = np.array([[1,2,3,4,5,6,7],[8,9,10,11,12,13,14]])

print(a[:, 2])
👉 array([ 3, 10])
a = np.array([[1,2,3,4,5,6,7],[8,9,10,11,12,13,14]])

print(a[0, 1:-1:2])
👉 array([2, 4, 6])
25
Q

numpy.argwhere()

A

найти расположение элементов соответствующих условию заданному в скобках.

x = np.array([[0, 1, 2],
              [3, 4, 5]])

print(np.argwhere(x > 0))
👉 [[0 1]
    [0 2]
    [1 0]
    [1 1]
    [1 2]]

print(np.argwhere(x > 3))
👉 [[1 1]
    [1 2]]
26
Q

numpy.logical_and(x1, x2, /, out=None, *, where=True, casting=’same_kind’, order=’K’, dtype=None, subok=True[, signature, extobj])

A

Compute the truth value of x1 AND x2 element-wise.

print(np.logical_and(True, False))
👉 False
print(np.logical_and(True, True))
👉 True
np.logical_and([True, True], [False, True])
👉 array([False  True])
x = np.arange(5)
np.logical_and(x>1, x<4)

👉 array([False, False,  True,  True, False])
27
Q

numpy.logical_or(x1, x2, /, out=None, *, where=True, casting=’same_kind’, order=’K’, dtype=None, subok=True[, signature, extobj])

A

Compute the truth value of x1 OR x2 element-wise.

np.logical_or(True, False)
👉 True
np.logical_or([True, False], [False, False])
👉 array([ True, False])
x = np.arange(5)
np.logical_or(x < 1, x > 3)
👉 array([ True, False, False, False,  True])
a = np.array([True, False])
b = np.array([False, False])
a | b
👉 array([ True, False])
28
Q

numpy.logical_not(x, /, out=None, *, where=True, casting=’same_kind’, order=’K’, dtype=None,
subok=True[, signature, extobj])

A

Compute the truth value of NOT x element-wise.

np.logical_not(3)
👉 False

np.logical_not([True, False, 0, 1])
👉 array([False,  True,  True, False])
x = np.arange(5)
np.logical_not(x<3)
👉 array([False, False, False,  True,  True])
29
Q

matplotlib.xscale(value, **kwargs)

A

Set the x-axis scale.

from matplotlib.ticker import EngFormatter
	
val = np.random.RandomState(19680801)
xs = np.logspace(1, 9, 100)
ys = (0.8 + 4 * val.uniform(size = 100)) * np.log10(xs)**2
	
plt.xscale('log')
plt.plot(xs, ys)
plt.xlabel('Frequency')
	
plt.title('matplotlib.pyplot.xscale() \
function Example\n', fontweight ="bold")
plt.show()
fig, ax4 = plt.subplots()
x = 10.0**np.linspace(0.0, 2.0, 15)
y = x**2.0
plt.xscale("log", nonposx ='clip')
plt.yscale("log", nonposy ='clip')
	
plt.errorbar(x, y, xerr = 0.1 * x, yerr = 2.0 + 1.75 * y, color ="green")
plt.ylim(bottom = 0.1)
	
plt.title('matplotlib.pyplot.xscale() \
function Example\n', fontweight ="bold")
plt.show()
30
Q

matplotlib.set_yticks(ticks, labels=None, *, minor=False, **kwargs)

A

Set the yaxis’ tick locations and optionally labels. If necessary, the view limits of the Axis are expanded so that all given ticks are visible.

np.random.seed(19680801)
  
x = np.linspace(0, 2 * np.pi, 100)
y = np.sin(x)
y2 = y + 0.2 * np.random.normal(size = x.shape)
  
fig, ax = plt.subplots()
ax.plot(x, y)
ax.plot(x, y2)
  
ax.set_yticks([-1, 0, 1])
  
ax.spines['left'].set_bounds(-1, 1)
ax.spines['right'].set_visible(False)
ax.spines['top'].set_visible(False)
  
fig.suptitle('matplotlib.axes.Axes.set_yticks()\
 function Example\n\n', fontweight ="bold")
fig.canvas.draw()
plt.show()
31
Q

matplotlib.imread(fname, format=None)

A

Read an image from a file into an array.

import matplotlib.cbook as cbook
import matplotlib.image as image
  
with cbook.get_sample_data('loggf.png') as image_file:
    image = plt.imread(image_file)
  
fig, ax = plt.subplots()
ax.imshow(image)
ax.axis('off')
plt.title('matplotlib.pyplot.imread() function Example', fontweight ="bold")
plt.show()
import matplotlib.cbook as cbook
import matplotlib.image as image

with cbook.get_sample_data('loggf.png') as file:
    im = image.imread(file)
  
fig, ax = plt.subplots()
ax.plot(np.cos(10 * np.linspace(0, 1)), '-o', ms = 15, alpha = 0.6, mfc ='green')
ax.grid()
fig.figimage(im, 10, 10, zorder = 3, alpha =.5)
  
plt.title('matplotlib.pyplot.imread() function Example', fontweight ="bold")
plt.show()
32
Q

numpy.linspace(start, stop, num=50, endpoint=True, retstep=False, dtype=None, axis=0)

A

Вернет интервал между старт и стоп в количестве заданом в намс.

np.linspace(2.0, 3.0, num=5)
👉 array([2.  , 2.25, 2.5 , 2.75, 3.  ])
np.linspace(2.0, 3.0, num=5, endpoint=False)
👉 array([2. ,  2.2,  2.4,  2.6,  2.8])
np.linspace(2.0, 3.0, num=5, retstep=True)
👉 (array([2.  ,  2.25,  2.5 ,  2.75,  3.  ]), 0.25)
33
Q

numpy.sin(x, /, out=None, *, where=True, casting=’same_kind’, order=’K’, dtype=None,
subok=True[, signature, extobj])

A

Trigonometric sine, element-wise.

np.sin(np.pi/2.)
👉 1.0
np.sin(np.array((0., 30., 45., 60., 90.)) * np.pi / 180. )
👉 array([ 0.        ,  0.5       ,  0.70710678,  0.8660254 ,  1.        ])
import matplotlib.pylab as plt
x = np.linspace(-np.pi, np.pi, 201)
plt.plot(x, np.sin(x))
plt.xlabel('Angle [rad]')
plt.ylabel('sin(x)')
plt.axis('tight')
plt.show()
34
Q

numpy.sort(a, axis=- 1, kind=None, order=None)

A

Return a sorted copy of an array.

a = np.array([[1,4],[3,1]])

np.sort(a)                
👉 array([[1, 4],
          [1, 3]])
a = np.array([[1,4],[3,1]])

np.sort(a, axis=None)     
👉 array([1, 1, 3, 4])
a = np.array([[1,4],[3,1]])

np.sort(a, axis=0)       
👉 array([[1, 1],
          [3, 4]])
35
Q

numpy.linalg

A

NumPy linear algebra functions rely on BLAS and LAPACK to provide efficient low level implementations of standard linear algebra algorithms.

36
Q

numpy.copy(a, order=’K’, subok=False)

A

Return an array copy of the given object.

np.array(a, copy=True)
x = np.array([1, 2, 3])
y = x
z = np.copy(x)
x[0] = 10
x[0] == y[0]
👉 True

x[0] == z[0]
👉 False
37
Q

numpy.random.permutation(x)

A

Randomly permute(перестановка) a sequence, or return a permuted range. If x is a multi-dimensional array, it is only shuffled along its first index.

np.random.permutation(10)
👉 array([1, 7, 4, 3, 0, 9, 2, 5, 8, 6])
np.random.permutation([1, 4, 9, 12, 15])
👉 array([15,  1,  9,  4, 12])
arr = np.arange(9).reshape((3, 3))
np.random.permutation(arr)

👉 array([[6, 7, 8],
          [0, 1, 2],
          [3, 4, 5]])
38
Q

numpy.ndarray.size

A

Number of elements in the array.

x = np.zeros((3, 5, 2), dtype=np.complex128)
x.size
👉 30

np.prod(x.shape)
👉 30
39
Q

numpy.dtype(dtype, align=False, copy=False)

A

Create a data type object. A dtype object can be constructed from different combinations of fundamental numeric types.

np.dtype(np.int16)
👉 dtype('int16')
np.dtype([('f1', np.int16)])
👉 dtype([('f1', '<i2')])
np.dtype([('f1', [('f1', np.int16)])])
👉 dtype([('f1', [('f1', '<i2')])])
np.dtype([('f1', np.uint64), ('f2', np.int32)])
👉 dtype([('f1', '<u8'), ('f2', '<i4')])
np.dtype([('a','f8'),('b','S10')])
👉 dtype([('a', '<f8'), ('b', 'S10')])
np.dtype([('hello',(np.int64,3)),('world',np.void,10)])
👉 dtype([('hello', '<i8', (3,)), ('world', 'V10')])
np.dtype({'names':['gender','age'], 'formats':['S1',np.uint8]})
👉 dtype([('gender', 'S1'), ('age', 'u1')])
40
Q

numpy.sqrt(x, /, out=None, *, where=True, casting=’same_kind’, order=’K’, dtype=None, subok=True[, signature, extobj])

A

Return the non-negative square-root of an array, element-wise.

np.sqrt([1,4,9])
👉 array([ 1.,  2.,  3.])
np.sqrt([4, -1, -3+4J])
👉 array([ 2.+0.j,  0.+1.j,  1.+2.j])
np.sqrt([4, -1, np.inf])
👉 array([ 2., nan, inf])
41
Q

__doc__

A

provides a documentation of the object.

def square(n):
    '''Takes in a number n, returns the square of n'''
    return n**2

print(square.\_\_doc\_\_)
👉 Takes in a number n, returns the square of n
class Dog:
    """Your best friend."""
    def do_nothing(self):
        pass

print(Dog.\_\_doc\_\_)
👉 Your best friend. 
def bark():
    """Wuff"""
    pass

print(bark.\_\_doc\_\_)
👉 Wuff
def bark():
    pass

print(bark.\_\_doc\_\_)
👉 None
42
Q

divmod(divident, divisor)

🎯 divident - делимое, число, которое вы хотите разделить
🎯 divisor - делитель, число, на которое вы хотите делить

A

возвращает кортеж, содержащий частное и остаток. Делит числа с остатком.

divmod(15, 8)
👉 (1, 7)
print(divmod(22, 7))
👉 (3, 1)
print(divmod(58, 10))
👉 (5, 8)
43
Q

scipy.stats.iqr(x, axis=None, rng=(25, 75), scale=1.0, nan_policy=’propagate’, interpolation=’linear’, keepdims=False)

A

Compute the interquartile range. IQR is the difference between the 75th and 25th percentile of the data. It is a measure of the dispersion similar to standard deviation or variance, but is much more robust(карает) against outliers .

from scipy.stats import iqr

x = np.array([[10, 7, 4], [3, 2, 1]])

iqr(x)
👉 4.0

iqr(x, axis=0)
👉 array([ 3.5,  2.5,  1.5])

iqr(x, axis=1)
👉 array([ 3.,  1.])
44
Q

SQL.TRIM()

A

removes leading and trailing spaces from a string.

SELECT TRIM("    SQL Tutorial    ") AS TrimmedString;

👉 SQL Tutorial
45
Q

SQL.CEIL()

A

returns the smallest integer value that is bigger than or equal to a number.

SELECT CEIL(25.75);
👉 26
46
Q

numpy.median(a, axis=None, out=None, overwrite_input=False, keepdims=False)

A

Compute the median along the specified axis.

a = np.array([[10, 7, 4], [3, 2, 1]])

print(np.median(a))
👉 3.5
a = np.array([[10, 7, 5], [3, 2, 1]])

print(np.median(a))
👉 4.0
a = np.array([[10, 7, 3], [3, 2, 1]])

print(np.median(a))
👉 3.0
a = np.array([[10, 7, 0], [3, 2, 1]])

print(np.median(a))
👉 2.5
a = np.array([[10, 7, 5], [5, 2, 1]])

print(np.median(a))
👉 5.0
a = np.array([[10, 7, 4], [3, 2, 1]])

print(np.median(a, axis=0))
👉 [6.5 4.5 2.5]
a = np.array([[10, 7, 4], [3, 2, 1]])

print(np.median(a, axis=1))
👉 [7. 2.]
47
Q

numpy.round_(a, decimals=0, out=None) and numpy.around(a, decimals=0, out=None)

A

Evenly round to the given number of decimals.

np.around([0.37, 1.64])
👉 array([0., 2.])
np.around([0.37, 1.64], decimals=1)
👉 array([0.4, 1.6])
np.around([.5, 1.5, 2.5, 3.5, 4.5]) # rounds to nearest even value
👉 array([0., 2., 2., 4., 4.])
np.around([1,2,3,11], decimals=1) # ndarray of ints is returned
👉 array([ 1,  2,  3, 11])
np.around([1,2,3,11], decimals=-1)
👉 array([ 0,  0,  0, 10])
48
Q

numpy.corrcoef(x, y=None, rowvar=True, bias=<no>, ddof=<no>, *, dtype=None)</no></no>

A

Return Pearson product-moment correlation coefficients.

rng = np.random.default_rng(seed=42)
xarr = rng.random((3, 3))

xarr
array([[0.77395605, 0.43887844, 0.85859792],
       [0.69736803, 0.09417735, 0.97562235],
       [0.7611397 , 0.78606431, 0.12811363]])

R1 = np.corrcoef(xarr)

R1
array([[ 1.        ,  0.99256089, -0.68080986],
       [ 0.99256089,  1.        , -0.76492172],
       [-0.68080986, -0.76492172,  1.        ]])
R3 = np.corrcoef(xarr, yarr, rowvar=False)

R3
array([[ 1.        ,  0.77598074, -0.47458546, -0.75078643, -0.9665554 ,
         0.22423734],
       [ 0.77598074,  1.        , -0.92346708, -0.99923895, -0.58826587,
        -0.44069024],
       [-0.47458546, -0.92346708,  1.        ,  0.93773029,  0.23297648,
         0.75137473],
       [-0.75078643, -0.99923895,  0.93773029,  1.        ,  0.55627469,
         0.47536961],
       [-0.9665554 , -0.58826587,  0.23297648,  0.55627469,  1.        ,
        -0.46666491],
       [ 0.22423734, -0.44069024,  0.75137473,  0.47536961, -0.46666491,
         1.        ]])
48
Q

numpy.corrcoef(x, y=None, rowvar=True, bias=<no>, ddof=<no>, *, dtype=None)</no></no>

A

Return Pearson product-moment correlation coefficients.

rng = np.random.default_rng(seed=42)
xarr = rng.random((3, 3))

xarr
array([[0.77395605, 0.43887844, 0.85859792],
       [0.69736803, 0.09417735, 0.97562235],
       [0.7611397 , 0.78606431, 0.12811363]])

R1 = np.corrcoef(xarr)

R1
array([[ 1.        ,  0.99256089, -0.68080986],
       [ 0.99256089,  1.        , -0.76492172],
       [-0.68080986, -0.76492172,  1.        ]])
R3 = np.corrcoef(xarr, yarr, rowvar=False)

R3
array([[ 1.        ,  0.77598074, -0.47458546, -0.75078643, -0.9665554 ,
         0.22423734],
       [ 0.77598074,  1.        , -0.92346708, -0.99923895, -0.58826587,
        -0.44069024],
       [-0.47458546, -0.92346708,  1.        ,  0.93773029,  0.23297648,
         0.75137473],
       [-0.75078643, -0.99923895,  0.93773029,  1.        ,  0.55627469,
         0.47536961],
       [-0.9665554 , -0.58826587,  0.23297648,  0.55627469,  1.        ,
        -0.46666491],
       [ 0.22423734, -0.44069024,  0.75137473,  0.47536961, -0.46666491,
         1.        ]])
49
Q

numpy.random.normal(loc=0.0, scale=1.0, size=None)

A

Draw random samples from a normal (Gaussian) distribution.

np.random.normal(3, 2.5, size=(2, 4))
array([[-4.49401501,  4.00950034, -1.81814867,  7.29718677],
       [ 0.39924804,  4.68456316,  4.99394529,  4.84057254]])