# Tag: scipy

## Solve a linear system of equations with bounds using LSQR/LSMR SciPy

Question is quite straight forward. I have an overdetermined system I am attempting to use SciPy LSQR (or LSMR) to solve. However, I cannot find anywhere in the docs on how to set restraints for the minimization. E.G. Let’s say this is the output: We can see the solution arrive to -0.1, which is great. However, I’d like to set

## Check result of chi square test on pandas columns data

I wrote the test according to an approach I found. When looking in Stack Overflow I saw another approach (can be seen here) which was a little more complicated, and made me wonder if I chose the right one. I’m looking for ways to check if my calculation is correct. Here is the relevant code: Any suggestions will be welcomed.

## How to make dotted line in a binary array

how to create the dotted line in the below NumPy array bh=make_figure(b,’gh’) requirement: how to convert element 1 into 0 with the step of two expected outputs is like I tried with a brute force algorithm, but I am not able to find the solution output array looks like for visual representation like making a dotted line Answer Here’s one

## Optimization problem for S-I-S model using python

I have a susceptible-infectious-susceptible model, to which I’ve written the following python code, And I’m solving it using the following code, This part is fine. I’m having trouble finding the double derivative and optimizing it for the value of the beta parameter. The problem is that the beta is not given and since that parameter is within the exponential function,

## Iterating row-wise over 2 pandas dataframes and passing these vectors as args to function

I’d like to iterate row-wise over 2 identically-shaped dataframes, passing the rows from each as vectors to a function without using loops. Essentially something similar to R’s mapply. I’ve investigated a little and the best that I’ve seen uses map in a list comprehension, but I’m not doing it correctly. Even if we get this to work, though, it seems

## scipy.stats.cumfreq() isn’t the cumulative frequency I’m looking for

Reading a statistic book, I’m also training with Python. My book asks me to calculate the cumulative workforce and the cumulative frequency of a simple list of jobs. Secteur Nombre d’emplois Agriculture 21143585 Construction 35197834 Industrie 69941779 Fabrication 64298386 Services 368931820 I wrote this Python program: that responds me: And if my book agrees for the cumulative workforce, it doesn’t

## How to fill in missing center of a 2d gaussian

I have a 2d gaussian whose center has been destroyed by pixel saturation. I need the center to be filled in because a poorly filled in center will confuse a neural network I’m trying to train. See below: The scattered nan values I can handle fairly easily, but the large cluster in the gaussian’s center I cannot. I’ve tried various

## PyVista mesh triangulation – vertex indices

I have a triangulated mesh that I generated with the Delaunay 3D function in PyVista. I would like to calculate the surface area of the mesh adding up the areas of all the triangles. Is there a way to obtain the indices of the simplices triangles from the delaunay result? I know I can do it with Scipy but for

## Why can’t I install a Python package with the Python requirement “>=3.8,<3.11" into a Poetry project with the Python version "^3.9"?

I’m having an issue installing dependencies into my Poetry project. If I run poetry new (as described in https://python-poetry.org/docs/basic-usage/), I can create a new project: My project structure looks like this after I delete a few files not needed for this reproduction: My pyproject.toml file looks like this: When I run poetry add scipy, it tries to install the latest

## scipy.signal.find_peaks return empty properties

I tried to obtain properties from scipy.signal.find_peaks, but it returns an empty dictionary {}. Can anyone help to fix it? Answer The problem is that you are passing None to prominence. None is already the default value, and is used to signal that no value for the argument was given. Pass a numeric value as below: Output