Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [python]

For mathematical questions about Python; questions purely about the language, syntax, or runtime errors are off-topic here and would likely be better received on Stack Overflow.

0
votes
0answers
22 views

Challenge : Finding the right minimized order of points.

There's stolen diamonds in a lot of different places. The places are on a coordinate system (x,y) where each place is named after a number and have an d-time for example: ...
0
votes
2answers
31 views

Second order Taylor method for solving ODE

Can anyone help me modify this code to second-order Taylor method? ...
1
vote
1answer
46 views

How to solve a non linear ODE with Newton's method?

Im trying to solve this ODE using the Newton method (for non-linear equations using Jacobian Matrix): $$ \frac{u''(x)}{(1+u'(x)^2)^{3/2}}=\frac TK u(x)+\frac{wx(x-L)}{2K} $$ original ode image $u(0) =...
1
vote
1answer
18 views

Translate point after rotation relative to different origin

I have 200x380 input image and coordinates (63,146) where (0,0) is top-left: I rotate about the centre some amount of degrees and expand the "canvas" to avoid cropping resulting in larger output ...
-3
votes
0answers
15 views

VBA Macro and ActiveX Button Consolidation [closed]

I have two Active X buttons that work and am trying to make one button that does both actions simulataneously. The first ActiveX button sorts through a data array and hides any rows that do not have ...
1
vote
0answers
23 views

Natural Cubic Spline beyond boundary guarantees constant slope?

my understanding is that for if I have five points, I can interpolate a natural cubic spline out of any five points with increasing x, because degree of freedom is five. But when I try the python ...
0
votes
0answers
25 views

Compute the radius and the central coordinate (x, y) of a circle constructed by three given points on the plane surface

I need you to explain the mathematics behind the code bellow. What is s, what are those formulas for px and py and generally, what logic are we following to find the answer here? ...
-1
votes
0answers
7 views

recursive trace recursive in scalable sense?

I was wondering if there is a way to explain the movement to all the possible variations of the movement fw1 left(1*n) fw2 left(2*n).... fwx, left(x*n) tracing its movement in a way that is recursive(...
0
votes
0answers
14 views

Elevation profiles approximation with polynomials/splines

enter image description hereI am to approximate natural ground elevation profiles with a mathematical function. Let say the elevation profiles can be approximated with ...
0
votes
0answers
20 views

Help translating this MAPA algorithm to Python (Math > Code)

Disclaimer: I'm a very amateur math enthusiast coming from a programming background. I'm working on a trading algorithm in which at this point in time is primarily based on an RSI indicator (...
2
votes
2answers
96 views

How to calculate the exact probability that the second player wins?

Consider a game that uses a generator which produces independent random integers between 1 and 100 inclusive. The game starts with a sum S = 0. The first player adds random numbers from the generator ...
1
vote
0answers
26 views

Time complexity of finding neighbors of specific nodes within a threshold in a weighted graph

Let $G$ be a weighted graph and the weights are in the range $[0,1]$. Consider the list $A=[a,b,c,d]$ as a list of nodes we want to find the neighbors of each within a specific threshold $T$. What is ...
5
votes
2answers
54 views

Why homogenise these vectors?

I was looking for a solution for finding two intersecting lines. I am aware that this can be done by finding a vector product of two lines. I have stumbled upon this example here: https://...
0
votes
0answers
29 views

Legendre Transform

I am facing a problem with the function x(p). I could not determine it, and so I was wondering if you could help me out with it. Is there a theorem I could rely on to solve the problem ? Thank you ...
0
votes
1answer
31 views

How to create a Toeplitz matrix from a vector

I have to create a Toeplitz matrix of a suitable form from a given vector The vector is $\;\{x[0],x[1],x[2] ... x[L-1]\}$ The matrix is of the form \begin{bmatrix}x[0]&x[1]&x[2]&...&...
0
votes
1answer
40 views

Need Algorithm or sequences of steps to solve this problem.

It's 2009 and you are staying in Oak City for the summer. Because of its history leading to people-centric urban planning, it has a free, well-planned, and timely public transit system, unlike the MTA....
1
vote
0answers
27 views

Singular Values of an $n$ dimensional matrix

I am interested in calculating the maximum singular value of an $n$ dimensional matrix in python. Can I reshape this matrix as a $2$-D matrix and calculate its operator norm? Are the singular values ...
1
vote
1answer
35 views

Multigraph enumeration with connection number limitation of nodes

I need to generate multigraphs by several labeled nodes. Each node has a limitation of connection number, and they always higher or equal than 3. For example: ...
0
votes
0answers
43 views

How can I compute similarity/distance between two multidimensional matrices?

I have two matrices with numeric and nominal data types (categories). Both matrices are multidimensional and don't have the same number of elements (lines). Examples: Matrix 1: [[2,"Peru",29,"Green"]...
1
vote
0answers
13 views

Color scatter plot points depending on third value in matplotlib pyplot

I have a dataset with a million of points like: 1.0,9.5,-0.3 2.3,4.8,0.7 8.1,3.6,0.0 3.9,1.4,-0.1 4.7,5.3,0.0 and PyPlot code like ...
0
votes
1answer
72 views

How to find a new equidistant vector, given 5 existing vectors?

Vectors v1, v2, v3, v4, V5, with 100 dim each, how to find a center vector, that will have equal distance with each? preferably if there is a way done in Python or Numpy.
2
votes
1answer
65 views

How to change this Runge-Kutta method implementation from first order ode solver to system of ODEs solver?

I implemented 4-step Runge-Kutta method (k1..k4) ODE solver for a function $u'(x) = f(x,u(x))$ with initial condition $u(x_0) = u_0$ But it solves just ODEs of the first order. How could I change ...
2
votes
1answer
62 views

How to use eigenvalues and eigenvectors to compute $A^{1000}$

$$A= \begin{bmatrix} 0.9 & 0.15 & 0.25 \\ 0.075 & 0.8 & 0.25 \\ 0.025 & 0.05 & 0.5 \\ \end{bmatrix} $$ I need to use a Python script to compute $A^{1000}$. ...
0
votes
1answer
23 views

Predicting capacity problems based on historical data

Situtation: An oil-company collects waste oil from small car/truck workshops. The workshops have only limited waste oil storage varying per workshop. Oil must be collected from those workshops when ...
0
votes
1answer
13 views

What if correlation coefficient is much less whereas the p-values is much lesser than the our significance level?

I have a data between rating of the restaurant and the approximate price of food in the restaurant. After doing Hypothesis testing. The pearson correlation coefficient was found to be 0.33 whereas p ...
0
votes
1answer
39 views

Monty Hall Problem simulation gives weird answers

I tried to simulate the Monty Hall problem in Python, and ended up with 66% probability after a few attempts. However, the first incorrect attempts were more interesting, as they consistently gave a ...
0
votes
1answer
63 views

Exercise of quadrature and error.

I am trying to solve the following problem, but I can not understand it(in the school they did not teach us quadrature). From the nodes $x_0 = \frac{2}{3}$, $x_1 = \frac{5}{9}$ and $x_2 = \frac{65}{...
1
vote
0answers
122 views

Calculating the Distance Matrix from Adjacency Matrix

How would I calculate the distance matrix of a connected, simple and undirected graph from the adjacency matrix? I have 56 nodes, if that is helpful, and would need to the answer to return an array. ...
0
votes
0answers
17 views

Confidence ellipsoide for bivariate gaussian and algebra linear

I would like to be able to plot the confidence ellipsoide knowing the covariance matrix of a bivariate gaussian vector. 1) How would you implement it in Python ? 2)For those who didn't manage it i ...
0
votes
0answers
16 views

How to display a 2d manifold of points?

I have created a manifold for a set of discrete (integer) points which lie in 2 dimensions. The manfiold has dimensions of $N\times N$ and I have a metric which dictates the seperation between the ...
3
votes
3answers
182 views

Intersection point of 2 lines defined by 2 points each

I'm implementing this in code, but I'll rewrite it so that it is easier understood (like pseudocode): ...
3
votes
0answers
65 views

How can I generate tilings using a computer? [closed]

I was reading this wikiperdia article on polyminos. The pictures look very nice. Example I want to learn how to generate these figures myself in an interactive way. Basically I want to start with a ...
0
votes
0answers
20 views

How can I calculate the GPS coordinate of an object in an image using the distance, angle and GPS coordinate of the center of the image in python? Ask

I'm trying to find the GPS location of an object within an aerial image at an altitude of 10m. I already have the GPS coordinates of the image itself (center) and the distance between the center and ...
0
votes
0answers
24 views

Using scipy's odeint to solve pde

I would like to use scipy's odeint to solve the following pde: $$\frac 1 r \frac {\partial u} {\partial r} + \frac {\partial^2 ...
0
votes
0answers
27 views

Interrogating the results of a Markov-chain simulation - Help and feedback highly appreciated

I have built a Markov chain which simulates the daily routine of German residents (activity patterns). Each simulation day is divided into 144-time steps and the person can carry out one of fourteen ...
0
votes
1answer
37 views

Simulating from a piecewise distribution

I have the following density function: $f(t)=\begin{cases} 0.8\exp(-2t)+0.5 \sqrt\frac{2}{\pi}\exp(-\frac{t^2}{2}) \text{, if } t > 2 \\0.8\exp(-2t)+0.5 \sqrt\frac{2}{\pi}\exp(-\frac{t^2}{2})+0....
0
votes
1answer
16 views

How to find boundaries to separate peaks in 3D

Peaks can be viewed as a grid of gaussians (as shown in the 3D plot below), but the centers are not exactly in straight lines. My questions is how to generate boundaries to separate these peaks. ...
1
vote
3answers
132 views

Probability that rolling dice that two dice sum to X

New here. I'm trying to figure out how to come up with a roll system for a game, where i want the probability of rolling N dice or rolling one dice N times and then taking the two largest outcomes, ...
-1
votes
4answers
49 views

coding in python that it sums a number that the user will give [closed]

i want to make a python program that ask from the user a number and the program should sums up the first n squares as long as the sum is smaller (not smaller than or equal to) than the numb er that ...
0
votes
1answer
61 views

Use matplotlib to plot the functions $y = x^3 + 3x^2 - x + 0.3\ $ and $y = \sin x$ [closed]

I'm new to Python coding and wondered if someone could give me the coding to plot these two graphs on the same program. This is what I have so far, exactly as typed on Python, however I know that ...
0
votes
0answers
22 views

Binomial Probability Number of Trials Formula and Code

This is an interview question I've had. Your number space is between 0 to N. You can only draw M random samples from 0 to N (N >= M). How many times (T) would you need to draw from your number space ...
0
votes
0answers
15 views

How to vectorize/matricize multivariate Gaussian PDF for more efficient computation?

Context: I was recently implementing (in Python) the Expectation-Maximization (EM) algorithm for Gaussian mixture models, and part of that process involves computing the Gaussian PDF for various ...
1
vote
2answers
77 views

Hackerrank matchstick experiment

The problem is regarding probability. The problem is given in detail here. In an $m \times n$ grid, $2mn -m -n$ matchsticks are placed at the inner boundaries between squares on the grid. We can ...
0
votes
0answers
24 views

Find boundaries to separate peaks in a 3D plot using matlab or python

Could you tell me how to find boundaries to separate the peaks in the 3D plot below? Ideally, the boundaries are at the local minimum. Peaks can be generated using Gaussian distributions with some ...
2
votes
0answers
55 views

How can I calculate Feigenbaum's constant?

So I am trying to calculate Feigenbaum's constant for the logistic map: $$ x_{n+1} = 4 \lambda x_n (1-x_n) $$ I am writing this through python and the main pieces I have for my code that are relevant ...
0
votes
1answer
37 views

quadratic bezier to parabola matrix equation

I'm trying to follow the matrix equation solution presented here: Convert quadratic bezier curve to parabola by @robjohn I'm assuming his solution can be used for any quadratic coordinates. My goal ...
0
votes
3answers
100 views

Inverse Matrix in Python

My understanding is that I can use Python to initialize my matrix and then apply an inverse function to find the solution.
0
votes
1answer
24 views

Correct notation for broadcasting operation

In Python numpy a row vector $u \in \mathbb{R}^n$ and its transposed $u^T$ can be added, multiplied or subtracted, yielding a $\mathbb{R}^{n\times n}$ matrix, where each element $(i,j)$ is the ...
1
vote
0answers
57 views

How to implement boundary value in Python using spectral methods

I want to solve the heat equation $$u_t=au_{xx},\quad 0\leq t, \ 0\leq x\leq\pi$$ in Python using spectral methods. I set $u(0,x)=\sin(x)$ as initial value for the time and choose $a=2$. My Code: <...
0
votes
0answers
24 views

How would I get the Heaviside function to be period in my solution?

so I am trying to solve an RC circuit problem that represents the square wave. Which I have already done on paper and now I am trying to plot it. So for this problem, we solved it using two methods, ...