# Questions tagged [numpy]

NumPy is the fundamental package for scientific computing with Python.

151 questions
Filter by
Sorted by
Tagged with
32 views

### Generating multivariate random variable with normal and exponential marginals

I have a collection of data points of the form $[U, V, X, Y]$, where $U$ ~ $N(\mu_1, \sigma_1)$; $V$ ~ $N(\mu_2, \sigma_2)$; $X$ ~ $exp(\lambda_1)$; and $Y$ ~ $exp(\lambda_2)$, and I am looking to ...
• 123
1 vote
37 views

### Logistic regression with SGD getting low error with high learning rate

The thing is that I am implementing LR with SGD. Here is my cross error function: ...
• 41
19 views

### Regression analysis with max value

I am trying to find the best curve that will describe my data. my data are stored in numpy arrays of t and dur they are both in ...
810 views

### Statistically compare two large continuous datasets

I have multiple images with 1 band/channel. This of an RGB image, then I only have the blue band/channel. In other words, multiple 1D datasets, or multiple 1D arrays. I would like to statistically ...
• 217
1 vote
88 views

### Gradient of a multivariate function numpy

I'm trying to calculate the gradient of multivariate function g using NumPy. g = lambda w: -np.sin(np.pi*np.sum(w**2)) + np.log(np.sum(w**2)) ...
1 vote
30 views

### Positive semi definite matrix with negative eigenvalues?

From what I know, for any square real matrix A, a matrix generated with the following should be a positive semidefinite (PSD) matrix: ...
1 vote
18 views

### Working with sparse data in numpy and sklearn [closed]

I have a time series dataset geenrated from some electrophysiological data. I have a frequncy dataset and the matrix is quite sparse but huge, like it contains 0.005 s time bins for 2000+ neurons ...
103 views

### RMSE, MAE and MAPE reduced but RMSPE increased after removing outliers in linear regression

I am using a linear regression model with 465 datapoints to predict crop yield of wheat. The data points are spilt into training and testing sets in 80:20 ratio. Initially, I tried linear regression ...
27 views

### Sklearn PCA projection differences while reproducing projection sample by sample

I've been stuck on this issue due to inability to reproduce the performance of PCA-classification pipeline on training data, but in case the pipeline receives one sample at a time. This seems to be ...
12 views

### Preprocessing protocol to derive wavelength from slanted wave profile

I am trying to derive a wavelength from sediment wave profiles. In some instances with the data, the sediment waves occur on a slope. This slope can be straight or curved depending on each instance. ...
1 vote
50 views

### How do I get the stationary distribution of a Markov chain matrix from SVD?

I have a matrix that represents a Markov chain. ...
• 1,298
1 vote
41 views

### Probability of drawing N elements from M elements with per element draw probability without replacement

I have a list of M elements with per element draw probability, summing to 1.0. Example (M=10): L = [0.3, 0.2, 0.01, 0.05, 0.02, 0.02, 0.2, 0.05, 0.05, 0.1] Now I ...
107 views

### Implement permutation test for difference of means (procedure described in linked book) in Python

Asked also on Stack Overflow. Question summary: I've implemented method described in a book and got results different than expected. What am I doing wrong? Consider the following problem: farmer is ...
238 views

### How to sample from non-gaussian dataset [duplicate]

Let's say I have a small dataset (normalized), that doesn't necessarily follow a gaussian distribution. We can see that by plotting it on a simple histogram. There is clearly a bias. There is also a ...
18 views

### how update weight in multivariate regression with MAE

i was working with RMSE loss function .i implemented the rmse loss function and it's gradiant to update my weights in multivariate regression [ w0x1 + w1x2+... +wnxn+ b] and that was ok .like below ...
73 views

### I'm performing a multi linear regression on the The Oxford Covid-19 Government Response Tracker. I have a couple of doubts about the process

I hope this is the right place to ask this. I'm currently working my way through a dataset and performing Multiple Linear Regression on it. The data is for Oxford Governement Response Tracker for the ...
1 vote
76 views

### Behaviour of intralayer (lateral) connections in neural network during training

I am interested in experimenting with some very simple neural network architectures by building them in numpy. I have followed a course in how to build a feed-forward multilayer neural network in ...
404 views

### How can i get the phase difference between two frequencies?

I have two signals of the same frequency. Both have frequencies of 13.56Mhz, and I want to find the phase difference between these two frequencies. The function generator generates a sinusoidal ...
23 views

### Generate truncated lognormal distribution using numpy [duplicate]

I am using [numpy.random.lognormal][1] to generate distribution based on mean and std. of ...
• 490
354 views

### Getting the slope of the first principal component from PCA

"Given an Nx2 dataset get the first principle component then it's slope."I'm working through how to get the slope of the first principal component in PCA using Numpy ...
• 640
1 vote
990 views

### How to sample from truncated distributions using scipy?

I have min and max values for certain variables such as: Expenses Loss Growth I'd like to add a distribution around them and plot a histogram in python. Distribution could be beta, gamma right type ...
• 490
56 views

### Difference between plt.xcorr() at (1+)-lag and np.corrcoef()

I use plt.xcorr() function to plot cross-correlation between time series: ...
• 39
188 views

### How to create and solve a underdetermined nonlinear system of equations using python

as i already mentioned in the header my plan is to create and solve a system of nonlinear equations in python. As I also mentioned, the equations system will be underdetermined. I will try to give an ...
30 views

### Standard deviation cap crosses zero

Let's say I have some reference data and some predicted data and I want to show the standard deviation of the mean absolute error. When I create error bar using numpy and matplotlib, errorbar crosses ...
• 111
562 views

### In Python, can I use mean, median, minimum, maximum, standard deviation, population size, and single sample to generate statistically identical data?

Example situation After each exam, the professor provides the following information. Minimum Score [Arithmetic] Mean Median Maximum Score Standard Deviation I also know what my score was as well as ...
• 1
83 views

### Visualize PCA, train or test?

I am new to PCA and have a question about visualization when it comes to fitting and transposing. I have two data, which are train and test. Here are four methods: ...
• 9
32 views

### What I have this rare output value of variance and standart deviation functions in numpy? [duplicate]

Hell i have nonsense values of variance and standart deviation in numpy. this documentation no make sense with this sample. https://numpy.org/doc/stable/reference/generated/numpy.std.html youtube ...
673 views

### When does MAPE (Mean Absolute Percentage Error) fail?

I have a multioutput regression model that predicts float values. When using MAPE to evaluate regression model performance (using either built in libraries or implementing a function for it) I am ...
• 101
1 vote
445 views

### Numpy.cov() in Python returning a matrix of NaN's instead of 0's [closed]

The cov() method from the numpy library returns a covariance matrix where columns represent different features and rows represent separate instances of the same feature. Therefore, passing a nx1 ...
• 121
1 vote
453 views

### Numpy and Statmodel issue - LinAlgError - Singular Matrix

I have seen other topics on this, but I couldn't get their solutions working for me. Perhaps someone else will know why. namely: statsmodels: error in kde on a list of repeated values However, my ...
• 111
50 views

### Stats Model contingency table, unable to reshape data and run test for nd array 2 x 2 x k

Consider below list of 2×2 tables and CMH (Cochran–Mantel–Haenszel) test results. We are trying to determine if each specific centre was associated with the success of the treatment [Data from Agresti,...
• 125
160 views

• 189
2k views

### Violin plot of 2 numpy arrays with seaborn

I would like to compare the distribution of 2 numpy arrays using a violin plot made with seaborn. The maximal value in both arrays is 1. The plot suggests a higher maximum. Am I misunderstanding the ...
33 views

### Neural network from scratch: only predicts training inputs correctly [duplicate]

Here is a neural network I've been working on. It takes in an array of four zeros or ones and predicts whether that pattern of zeros and ones is a backslash. ...
• 1
80 views

### Predicting new values after feature scaling

I am trying to do linear regression with one feature only: predicting height with weights. Gradient descent took too many epochs so I used a min max scaler and it converged to the optimum point pretty ...
73 views

### Basic RNN sequence classifier diagram?

I'd like to build an RNN in numpy from scratch to really get come comfortable with backpropagation through time (BPTT.) In the below diagram and LaTeX, I show two neurons, each with a non-linearity, N(...
• 1,700
85 views

### Why sampling different random variables sequencially using the same PRNG alters the sequence that would be obtained if only one was sampled?

When using random variables in most programming languages the usual process is based on instatiating a RandomGenerator which will output an stream of pseudo-random numbers and with this stream the ...
78 views

### Neural network based on twitter followers, what would be my features?

I was thinking of training a neural network that would be able to classify twitter users according to their followers. For example, I would like to know if a user is "gamer" or not by the people they ...
1 vote
2k views

### representing quantile like quartile in form of normal distribution curve

I learned in statistics the first quartile, 2nd quartile, and 3rd quartile can be represented in the figure1 below I came across this part of the article Step 4 - Feature Engineering.In this portion ...
• 111
3k views

### How to plot the prior, posterior and likelihood function from given data in python [closed]

I wrote a simple bayesian program which calculates prior, posterior and likelihood in python. ...
• 2,031