Tyberius
  • Member for 4 years, 9 months
  • Last seen this week
Converting distance matrix back into original data
Accepted answer
5 votes

This is more generally known as the distance geometry problem where we are trying to reconstruct data points given distances between all or some of the points with respect to some distance metric. A ...

View answer
In a random walk simulation, how do I get the mean and standard deviation of how many times the walk returns to the origin?
Accepted answer
3 votes

At the moment, you aren't tracking the number of times a walk reaches zero or even if a walk reaches zero at any point. Your Move function returns the last position of the walk, so you are only ...

View answer
Forming a particular (averaged) block matrix with numpy
3 votes

mats_row=np.array([[A1,A2,A3,...,A_n]]) #Create array of matrices with shape (1,M,N,N) mats_column=np.transpose(mats_row,(1,0,2,3)) #Make a copy with shape (M,1,N,N) block=.5*(mats_row+mats_column) #...

View answer
Compute $tr(A^TBC)$ in Python
Accepted answer
3 votes

Another nice way to do this sort of thing is numpy.einsum, which allows you to express the multiplication in index notation: >>> A=np.array([[1,2,3],[4,5,6]]) >>> B=np.array([[1,2],[...

View answer
integrate.solve_ivp bugged
Accepted answer
3 votes

Your issue is that you are modifying y in your function. If you return, [u,v] instead of resetting the values in y, it seems to run just fine. I believe this is because the solver will store and use ...

View answer
Schrodinger's Equation differential
Accepted answer
2 votes

Your code has a small issue that is distorting the amplitude. You are not initializing p[1], which throws off the Verlet steps right from the beginning. If you have this set, the amplitude will stay ...

View answer
SciPy odeint giving different results with matrix multiplication
Accepted answer
2 votes

I focused on the second function initially, assuming the first was correct, but I realize the issue is actually in the first function. Your matrix multiplication is incorrect in the first function. It ...

View answer
Fitting using curve_fit of scipy in python gives totally different answer for 1/t and t
2 votes

Curve fitting can be very sensitive to your initial guess for each parameter. Because you don't specify a guess in your code, all of these parameters start with a value of 1. Comparing with the ...

View answer
Heineken Virus C program ( how to simplify and discard else if in my code)
Accepted answer
2 votes

With the way you have written it, where you enumerate all possible states (though it looks like you are still missing a few), you can do the valid cases first, then just have invalid grouped into a ...

View answer
How to solve a BVP with known parameters?
1 votes

It looks like solve_ivp also didn't have args until fairly recently, see the issue on GitHub. The workaround they suggest there is to use a lambda expression around your function, which will have the ...

View answer
Roothaan equations and Galerkin method
Accepted answer
1 votes

Yes, that equation comes about from making the approximation that we can write the wavefunction in terms of a finite basis. You won't typically see the phrase Galerkin used in the chemical literature, ...

View answer
solve_ivp doesn't work with toms748
Accepted answer
1 votes

I'm not certain of the exact error, but the issue seems to stem from tom748 when you pass in an array/list r to E rather than a scalar, though I'm not sure why it only seems to happen when solveivp ...

View answer
How is the fuzzy logic calculated in scikit-fuzzy?
Accepted answer
1 votes

The approach that they use proceeds something like this. 1. Convert quality/service membership to tip membership. Since quality and service have no membership in the "bad"/"poor" ...

View answer
Looping in Python to find additional vectors using a given initial condition
1 votes

import numpy as np def vectors(max_n,max_t,k=0.05,l=0.01): times = np.arange(1,max_t,1) ##exclude t=0, set in initial condition indicies = np.arange(0,max_n,1) #initial conditions: F ...

View answer
Maximize a function of an orthogonal matrix
1 votes

I wound up using a different approach to get the optimization working. In the paper, they use an approach based on Jacobi rotations where they rotate pairs of modes by a calculated optimal angle to ...

View answer
What is the meaning of triangles color in the result of Tipping Problem in scikit-fuzzy (fuzzy logic)?
Accepted answer
0 votes

Rule Evaluation It may help to see their explanation of the rules for translating from service/quality to a tip. If the food is poor OR the service is poor, then the tip will be low If the service is ...

View answer
Confusion about bilinear form for elasticity equation in deal.ii tutorial
0 votes

Its not the summation that is wrong, but the lack of indices inside it. Below this expression on their site they define: $$\epsilon(\mathbf{u})=\frac{1}{2}([\nabla\mathbf{u}]+[\nabla\mathbf{u}]^{\...

View answer
Python documentation on creation of an exponential random variable
0 votes

From the source on GitHub, the function does accept $\beta$, so even if expressing the function in terms of $\frac{1}{\beta}$ (rather than $\lambda=\frac{1}{\beta}$) was typical, it is a bit ...

View answer