Question

the following are numpy arrays: x = [1 0] [0 1] y = [1 2] [3...

the following are numpy arrays:

x = [1 0]

[0 1]

y = [1 2]

[3 4]

what numpy function would put both of these arrays in to the following 4x4 matrix:

p = [x x]

[y y]

so it would like this:

p = [1 0 1 0]

[0 1 0 1]

[1 2 1 2]

[3 4 3 4]

Homework Answers

Answer #1

Here is the answer...

CODE:

import numpy as np
x = np.array([[1, 0],[0,1]])
y = np.array([[1, 2],[3,4]])
print(type(x))
print("X =",x)
print(type(y))
print("Y =",y)
p=np.column_stack([[x,x],[y,y]]) #here we arrange column wise


k=np.column_stack(p) #again arrange in column wise
m=np.asmatrix(k) #convert them to matrix
print("\nMatrix is")
print(m) #print matrix
print(m.shape,type(m)) #print its shape and type


CODE and OUTPUT:

If you have any doubts please COMMENT....

If you understand the answer please give THUMBS UP..

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Consider the following joint distribution between random variables X and Y: Y=0 Y=1 Y=2 X=0 P(X=0,...
Consider the following joint distribution between random variables X and Y: Y=0 Y=1 Y=2 X=0 P(X=0, Y=0) = 5/20 P(X=0, Y=1) =3/20 P(X=0, Y=2) = 1/20 X=1 P(X=1, Y=0) = 3/20 P(X=1, Y=1) = 4/20 P(X=1, Y=2) = 4/20 Further, E[X] = 0.55, E[Y] = 0.85, Var[X] = 0.2475 and Var[Y] = 0.6275. a. (6 points) Find the covariance between X and Y. b. (6 points) Find E[X | Y = 0]. c. (6 points) Are X and Y independent?...
Find the inverse matrix of [ 3 2 3 1 ] [ 2 1 0 0...
Find the inverse matrix of [ 3 2 3 1 ] [ 2 1 0 0 ] [ 3 -5 1 0 ] [ 4 2 3 1 ] This is all one 4x4 matrix Required first step add second row multiplied by (-1) to first row try to not use fractions at all to solve this problem
x y s t P 1 -3 1 0 0 12 1 2 0 1 0...
x y s t P 1 -3 1 0 0 12 1 2 0 1 0 3 -6 -4 0 0 1 0 The pivot element for the initial simplex tableau show is the red 1. So we need to zero out the other elements of column x. What is the formula used to zero out row 1 and column x? Multiply Row _____by_______ and then add the result to Row_____ What is the formula used to zero out row...
For the following set of data, X Y 1 0 2 2 3 4 4 6...
For the following set of data, X Y 1 0 2 2 3 4 4 6 5 8 a. Compute the Pearson correlation, r, for this data set. b. Re-arrange the Y scores so that the value of r = –1.00.
Suppose f(x,y)=(1/8)(6-x-y) for 0<x<2 and 2<y<4. Find p(0.5 < X < 1) and p(2 < Y...
Suppose f(x,y)=(1/8)(6-x-y) for 0<x<2 and 2<y<4. Find p(0.5 < X < 1) and p(2 < Y < 3) Find p(Y<3|X=1) Find p(Y<3|0.5<X<1)
GIVEN INFORMATION {X=0, Y=0} = 36 {X=0, Y=1} = 4 {X=1, Y=0} = 4 {X=1, Y=1}...
GIVEN INFORMATION {X=0, Y=0} = 36 {X=0, Y=1} = 4 {X=1, Y=0} = 4 {X=1, Y=1} = 6 1. Use observed cell counts found in the given information to estimate the joint probabilities for (X = x, Y = y) 2. Find the marginal probabilities of X = x and Y = y 3. Find P (Y = 1|X = 1) and P (Y = 1|X = 0) 4. Find P (X = 1 ∪ Y = 1) 5. Use...
a) Let y be the solution of the equation y ′ − [(3x^2*y)/(1+x^3)]=1+x^3 satisfying the condition  y...
a) Let y be the solution of the equation y ′ − [(3x^2*y)/(1+x^3)]=1+x^3 satisfying the condition  y ( 0 ) = 1. Find y ( 1 ). b) Let y be the solution of the equation y ′ = 4 − 2 x y satisfying the condition y ( 0 ) = 0. Use Euler's method with the horizontal step size  h = 1/2 to find an approximation to the value of the function y at x = 1. c) Let y...
Assume that X and Y has a continuous joint p.d.f. as (28x^2)*(y^3) in 0<y<x<1 interval. Otherwise...
Assume that X and Y has a continuous joint p.d.f. as (28x^2)*(y^3) in 0<y<x<1 interval. Otherwise the joint p.d.f. is equal to 0. Prove that the mentioned f(x,y) is a joint probability density function. Calculate E(X) Calculate E(Y) Calculate E(X2) Calculate Var(X) Calculate E(XY) Calculate P(X< 0.1) Calculate P(X> 0.1) Calculate P(X>2) Calculate P(-2<X<0.1)
X/Y 1 2 3 4 -1 0 0 0.1 0.2 0 0.1 0.1 0 0.1 1...
X/Y 1 2 3 4 -1 0 0 0.1 0.2 0 0.1 0.1 0 0.1 1 0.2 0 0.1 0.1 let the joint probability mass function of the discrete random variable X and Y give as above Find E(3x+1) and E(3x+4y) cov( X,Y)
Suppose that(X,Y)is uniformly distributed over the rectangular region with corners(0, 0),(2, 0),(2, 1),(0, 1). Compute the...
Suppose that(X,Y)is uniformly distributed over the rectangular region with corners(0, 0),(2, 0),(2, 1),(0, 1). Compute the following: (1)P{X=Y} (2)P{X < Y} (3)P{X < Y^2}