math

scipys quadrature function complains about perfectly sane lambda?

scipys quadrature function complains about perfectly sane lambda? Question: I have 2 versions of a snippet one works one doesn’t, this works: f = lambda x : x * 2.0 * pi print(scipy.integrate.quadrature(f, 0.0, 1.0)) This fails: f = lambda x : math.exp(x * 2.0 * pi)` print(scipy.integrate.quadrature(f, 0.0, 1.0)) With error: TypeError: only size-1 …

Total answers: 1

Playful cat and keyboard

Playful cat and keyboard Question: Problem: The keyboard on the screen of the mobile application consists of: 26 capital Latin letters, 10 digits 4 navigation keys: up, down, right and left. The application is open on a tablet, on which an unpredictable and consistent cat walks. The unpredictability of the cat is that all its …

Total answers: 1

How to find best fit line using PCA in Python?

How to find best fit line using PCA in Python? Question: I have this code that does it using SVD. But I want to know how to do the same using PCA. Online all I can find is that they are related, etc, but not sure how they are related and how they are different …

Total answers: 2

Sympy not simplifying polygamma

Sympy not simplifying polygamma Question: I have a python script that finds the derivative of a function, within which is the gamma function. When substituting values in, instead of finding the digamma of the values and returning it as a float, sympy only returns polygamma (0, 1.05) or whatever the output is. Below is my …

Total answers: 1

Python 3 matrix calculator

Python 3 matrix calculator Question: I have an issue with this code, It works wrong on option 7 at least is the main problem, It should do the matrix modify and save new value like 2A(A s 2) should be saved on A and maybe because it doesn’t update to new value it gives wrong …

Total answers: 2

bad operand type when using np.linalg.lstsq in python

bad operand type when using np.linalg.lstsq in python Question: I am trying to use np.linalg.lstsq to solve a problem, I started with simple arrays to solve the equation: CX = D where C = [[66.31835487 67.46962851 58.22702243] [67.46962851 68.65912117 59.24895075] [58.22702243 59.24895075 51.56007083]] D [0.01144368 0.01164468 0.01004645] ` I used: x = – np.linalg.lstsq(C, D, …

Total answers: 1

Split number into chunks according to rank

Split number into chunks according to rank Question: A very practical task. I have a number of items that need to be distributed into several stores, according to store rank. So the higher the rank, the more items store will get, so store with rank 1 will get most items and store with rank 100 …

Total answers: 1

Calculating probability distribution of an image?

Calculating probability distribution of an image? Question: I want to find the probability distribution of two images so I can calculate KL Divergence. I’m trying to figure out what probability distribution means in this sense. I’ve converted my images to grayscale, flattened them to a 1d array and plotted them as a histogram with bins …

Total answers: 1