array-broadcasting Questions

3

I am trying to implement a way to cluster points in a test dataset based on their similarity to a sample dataset, using Euclidean distance. The test dataset has 500 points, each point is a N dimens...
Wivinah asked 30/9, 2015 at 2:20

1

Assume we want to compute the dot product of a matrix and a column vector: So in Numpy/Python here we go: a=numpy.asarray([[1,2,3], [4,5,6], [7,8,9]]) b=numpy.asarray([[2],[1],[3]]) a.dot(b) ...
Outguess asked 5/1, 2016 at 8:41

1

Solved

I have the following 3rd order tensors. Both tensors matrices the first tensor containing 100 10x9 matrices and the second containing 100 3x10 matrices (which I have just filled with ones for this ...
November asked 30/12, 2015 at 1:52

1

Solved

From an array like db (which will be approximately (1e6, 300)) and a mask = [1, 0, 1] vector, I define the target as a 1 in the first column. I want to create an out vector that consists of ones w...
Demirelief asked 28/12, 2015 at 15:41

3

Solved

I have an operation that I'm doing commonly which I'm calling a "jagged-slice" because I don't know the real name for it. It's best explained by example: a = np.random.randn(50, 10) entries_of_int...
Harvest asked 16/11, 2015 at 12:58

1

Solved

Using the excellent broadcasting rules of numpy you can subtract a shape (3,) array v from a shape (5,3) array X with X - v The result is a shape (5,3) array in which each row i is the differen...
Catacaustic asked 12/11, 2015 at 17:5

1

Solved

I have a vector [x,y,z,q] and I want to create a matrix: [[x,y,z,q], [x,y,z,q], [x,y,z,q], ... [x,y,z,q]] with m rows. I think this could be done in some smart way, using broadcasting, but I...
Parsnip asked 18/10, 2015 at 16:55

3

Solved

I am attempting to add two arrays. np.zeros((6,9,20)) + np.array([1,2,3,4,5,6,7,8,9]) I want to get something out that is like array([[[ 1., 1., 1., ..., 1., 1., 1.], [ 2., 2., 2., ..., 2., ...
Sirree asked 29/8, 2015 at 7:26

2

Solved

I have a dataframe of shape (4, 3) as following: In [1]: import pandas as pd In [2]: import numpy as np In [3]: x = pd.DataFrame(np.random.randn(4, 3), index=np.arange(4)) In [4]: x Out[4]: 0 ...
Audiology asked 12/8, 2015 at 16:7

2

Solved

In python (using numpy), I can broadcast an array to a different shape: >>> import numpy as np >>> a = np.array([2,3,4]) >>> b = np.zeros((3,2)) >>> b[:,:] = np...
Slapup asked 3/2, 2013 at 2:49

1

Solved

Im using python 2.7 and am attempting a forcasting on some random data from 1.00000000 to 3.0000000008. There are approx 196 items in my array and I get the error ValueError: operands could ...
Tremain asked 8/8, 2012 at 1:34

4

Solved

I want to broadcast an array b to the shape it would take if it were in an arithmetic operation with another array a. For example, if a.shape = (3,3) and b was a scalar, I want to get an array who...
Barnstorm asked 24/7, 2012 at 0:57

© 2022 - 2024 — McMap. All rights reserved.