Category "numpy"

Create surrogate data in python using fourier transform?

I want to create 10,000 sample (random phase but same power spectra) of my original time series using fourier transform. The method I want to opt is given in fi

x and y must be the same size

Using python I'm trying to plot a sin wave and random distribution, then show where the ratio is greater than or equal to 3. I think I'm 90% of the way there bu

Generating constraints for optimization in scipy using loop

There are lots of constraints which I will use in optimization using scipy; so I need to generate the constraints by loop. Below there's a sample of my constrai

ValueError: Input 0 of layer hiddenL1 is incompatible with the layer: its rank is undefined, but the layer requires a define rank

I am trying to create a sequential keras model with custom weights. The weights come from a row in a numpy array. When running the code I get the error: Value

Blockwise reshape in numpy?

I have a numpy array with columns that are in blocks. I want to transpose the blocks. It's conceptually simple, and I guess one can do it simply, but I dont kno

How can I get last value of STOCHRSI with Ta-Lib?

I implemented it but it prints all. print(ta.STOCHRSI(df["close"], 14, 5, 3, 0)[-1]) 2022-04-20 17:00:00 NaN 2022-04-20 18:00:00 NaN 2022-04-

Applying a function to each timestep in an xarray.Dataset, and return lazy Dask array outputs

I have an xarray.Dataset with two 1D variables sun_azimuth and sun_elevation with multiple timesteps along the time dimension: import xarray as xr import numpy

Filling a 2D array with values from a 1D array, but using list comprehension

I'm trying to "paste" the values contained in the 1D array dataslice (1x8) into the 2D array values_matrix (9x9), following the position indices contained in th

Convert pandas data frame column, which has values of vectors, into tensors

My question is how to convert a vector on pandas data frame into tensors. The data frame has a resume column which has a vector representations of each resume d

Numpy vectorize excluded argument

Please I need someone to explain the function of excluded argument in Numpy vectorize function in a simple way.

What is the use of the data type 'intp' in NumPy?

I've seen the data types in the NumPy package of Python, but I found the description of the data type 'intp' a bit confusing. Its description is like: intp: Int

Eigenvectors in Julia vs Numpy

I'm currently working to diagonalize a 5000x5000 Hermitian matrix, and I find that when I use Julia's eigen function in the LinearAlgebra module, which produces

Ranking (not sorting) rows of 2D matrix lexicographically with numpy

I want to rank the rows of a 2D matrix lexicographically (in descending order) such that they are ranked: first by the left-most column, then second left-most c

Python: appending numpy.array to list python overwrites the previous elements

I'm trying to plot a stellar orbit in a given potential. First, I initialize the position and velocity, and derive the acceleration from the position according

How to guess the numerical Solution for Mathieu's Equation

am trying to predict the exact solution for the mathieu's equation y"+(lambda - 2qcos(2x))y = 0. I have been able to get five eigenvalues for the equation using

Movie Recommendation: Generate similar movies for all movies

I'm using scikit-learn TfldfVectorizer to produce the TF-IDF matrix #Import TfIdfVectorizer from scikit-learn from sklearn.feature_extraction.text import TfidfV

SymmetricalLogLocator not working with Contourf in Matplotlib

I have data in which values are ranging from small negative values to positive 1000. Since the minimum and maximum differ by large scales, I first set locator a

Finite difference method for 3D diffusion/heat equation

I'm trying to use finite differences to solve the diffusion equation in 3D. I think I'm having problems with the main loop. In particular the discrete equation

Install numpy for blender

I'm having a hard time exporting my blender model to glTF 2.0 format (for godot): (I still can export it to default .dae format) So, I tried installing numpy f

Efficiently get first N numbers that satisfy a condition in each row in a pytorch/numpy tensor

Given a tensor b, and I would like to extract N elements in each row that satisfy a specific condition. For example, suppose a is a matrix that indicates whethe