Consequences of projecting data onto lower dimensions
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.mlab as mlab
import math
na = 400
ma = [2, 1]
Sa = [[3, -2], [-2, 3]]
sigma1 = [3, 3]
nb = 400
mb = [8, 6]
Sb = [[3, -2], [-2, 3]]
xa, ya = np.random.multivariate_normal(ma, Sa, na).T
xb, yb = np.random.multivariate_normal(mb, Sb, nb).T
plt.plot(xa, ya, 'x')
plt.plot(xb, yb, 'x')
plt.axis('equal')
plt.show()
I have randomly generated data from 2-dimensional Gaussian Distributions and need to project this on w=[0, 1]
and plot the histogram. I tried using plt.hist
but it does not allow the multiplication.
python matplotlib
add a comment |
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.mlab as mlab
import math
na = 400
ma = [2, 1]
Sa = [[3, -2], [-2, 3]]
sigma1 = [3, 3]
nb = 400
mb = [8, 6]
Sb = [[3, -2], [-2, 3]]
xa, ya = np.random.multivariate_normal(ma, Sa, na).T
xb, yb = np.random.multivariate_normal(mb, Sb, nb).T
plt.plot(xa, ya, 'x')
plt.plot(xb, yb, 'x')
plt.axis('equal')
plt.show()
I have randomly generated data from 2-dimensional Gaussian Distributions and need to project this on w=[0, 1]
and plot the histogram. I tried using plt.hist
but it does not allow the multiplication.
python matplotlib
see stats.stackexchange.com/questions/201921/…
– teng
Nov 24 '18 at 0:02
Thanks for the link it was very useful. My difficulty is how I am going to be able to break down the 2d array to be able to do the dot product as my data when np= 10 is like this. [array([ 1.63383494, 4.6541953 , 2.10788923, 2.46806161, 1.87287563, 0.76323836, 2.95160091, 1.74592451, -1.27726486, 4.22058637]), array([ 2.48245559, 1.57752103, -1.23525301, -1.76199059, -0.38459408, 1.78905969, -2.03621301, 1.23246001, 1.89331416, -0.71733151])]. I know that the first projection should come out as [11/5; 5.75/5] when taking w as [2;1]
– Michelle Abela
Nov 24 '18 at 0:54
you'll need to cast the arrays asnp.array
and for dot product, usenp.dot
.
– teng
Nov 24 '18 at 0:57
1
Question has nothing to do withmachine-learning
- kindly do not spam the tag (removed).
– desertnaut
Nov 24 '18 at 0:58
add a comment |
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.mlab as mlab
import math
na = 400
ma = [2, 1]
Sa = [[3, -2], [-2, 3]]
sigma1 = [3, 3]
nb = 400
mb = [8, 6]
Sb = [[3, -2], [-2, 3]]
xa, ya = np.random.multivariate_normal(ma, Sa, na).T
xb, yb = np.random.multivariate_normal(mb, Sb, nb).T
plt.plot(xa, ya, 'x')
plt.plot(xb, yb, 'x')
plt.axis('equal')
plt.show()
I have randomly generated data from 2-dimensional Gaussian Distributions and need to project this on w=[0, 1]
and plot the histogram. I tried using plt.hist
but it does not allow the multiplication.
python matplotlib
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.mlab as mlab
import math
na = 400
ma = [2, 1]
Sa = [[3, -2], [-2, 3]]
sigma1 = [3, 3]
nb = 400
mb = [8, 6]
Sb = [[3, -2], [-2, 3]]
xa, ya = np.random.multivariate_normal(ma, Sa, na).T
xb, yb = np.random.multivariate_normal(mb, Sb, nb).T
plt.plot(xa, ya, 'x')
plt.plot(xb, yb, 'x')
plt.axis('equal')
plt.show()
I have randomly generated data from 2-dimensional Gaussian Distributions and need to project this on w=[0, 1]
and plot the histogram. I tried using plt.hist
but it does not allow the multiplication.
python matplotlib
python matplotlib
edited Nov 24 '18 at 0:59
desertnaut
18.1k73872
18.1k73872
asked Nov 23 '18 at 23:44
Michelle AbelaMichelle Abela
134
134
see stats.stackexchange.com/questions/201921/…
– teng
Nov 24 '18 at 0:02
Thanks for the link it was very useful. My difficulty is how I am going to be able to break down the 2d array to be able to do the dot product as my data when np= 10 is like this. [array([ 1.63383494, 4.6541953 , 2.10788923, 2.46806161, 1.87287563, 0.76323836, 2.95160091, 1.74592451, -1.27726486, 4.22058637]), array([ 2.48245559, 1.57752103, -1.23525301, -1.76199059, -0.38459408, 1.78905969, -2.03621301, 1.23246001, 1.89331416, -0.71733151])]. I know that the first projection should come out as [11/5; 5.75/5] when taking w as [2;1]
– Michelle Abela
Nov 24 '18 at 0:54
you'll need to cast the arrays asnp.array
and for dot product, usenp.dot
.
– teng
Nov 24 '18 at 0:57
1
Question has nothing to do withmachine-learning
- kindly do not spam the tag (removed).
– desertnaut
Nov 24 '18 at 0:58
add a comment |
see stats.stackexchange.com/questions/201921/…
– teng
Nov 24 '18 at 0:02
Thanks for the link it was very useful. My difficulty is how I am going to be able to break down the 2d array to be able to do the dot product as my data when np= 10 is like this. [array([ 1.63383494, 4.6541953 , 2.10788923, 2.46806161, 1.87287563, 0.76323836, 2.95160091, 1.74592451, -1.27726486, 4.22058637]), array([ 2.48245559, 1.57752103, -1.23525301, -1.76199059, -0.38459408, 1.78905969, -2.03621301, 1.23246001, 1.89331416, -0.71733151])]. I know that the first projection should come out as [11/5; 5.75/5] when taking w as [2;1]
– Michelle Abela
Nov 24 '18 at 0:54
you'll need to cast the arrays asnp.array
and for dot product, usenp.dot
.
– teng
Nov 24 '18 at 0:57
1
Question has nothing to do withmachine-learning
- kindly do not spam the tag (removed).
– desertnaut
Nov 24 '18 at 0:58
see stats.stackexchange.com/questions/201921/…
– teng
Nov 24 '18 at 0:02
see stats.stackexchange.com/questions/201921/…
– teng
Nov 24 '18 at 0:02
Thanks for the link it was very useful. My difficulty is how I am going to be able to break down the 2d array to be able to do the dot product as my data when np= 10 is like this. [array([ 1.63383494, 4.6541953 , 2.10788923, 2.46806161, 1.87287563, 0.76323836, 2.95160091, 1.74592451, -1.27726486, 4.22058637]), array([ 2.48245559, 1.57752103, -1.23525301, -1.76199059, -0.38459408, 1.78905969, -2.03621301, 1.23246001, 1.89331416, -0.71733151])]. I know that the first projection should come out as [11/5; 5.75/5] when taking w as [2;1]
– Michelle Abela
Nov 24 '18 at 0:54
Thanks for the link it was very useful. My difficulty is how I am going to be able to break down the 2d array to be able to do the dot product as my data when np= 10 is like this. [array([ 1.63383494, 4.6541953 , 2.10788923, 2.46806161, 1.87287563, 0.76323836, 2.95160091, 1.74592451, -1.27726486, 4.22058637]), array([ 2.48245559, 1.57752103, -1.23525301, -1.76199059, -0.38459408, 1.78905969, -2.03621301, 1.23246001, 1.89331416, -0.71733151])]. I know that the first projection should come out as [11/5; 5.75/5] when taking w as [2;1]
– Michelle Abela
Nov 24 '18 at 0:54
you'll need to cast the arrays as
np.array
and for dot product, use np.dot
.– teng
Nov 24 '18 at 0:57
you'll need to cast the arrays as
np.array
and for dot product, use np.dot
.– teng
Nov 24 '18 at 0:57
1
1
Question has nothing to do with
machine-learning
- kindly do not spam the tag (removed).– desertnaut
Nov 24 '18 at 0:58
Question has nothing to do with
machine-learning
- kindly do not spam the tag (removed).– desertnaut
Nov 24 '18 at 0:58
add a comment |
1 Answer
1
active
oldest
votes
Below links may be useful for learning numpy.
https://docs.scipy.org/doc/numpy-1.15.0/user/basics.creation.html
https://jakevdp.github.io/PythonDataScienceHandbook/02.02-the-basics-of-numpy-arrays.html
I think what you are asking is the below:
w = np.array([2,1])
a = np.array([xa,ya]).T
b = np.array([xb,yb]).T
aw = np.dot(a,w)
bw = np.dot(b,w)
plt.figure(0)
plt.hist(aw,label='a',histtype='step')
plt.hist(bw,label='b',histtype='step')
plt.title('projected')
plt.legend()
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53453957%2fconsequences-of-projecting-data-onto-lower-dimensions%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Below links may be useful for learning numpy.
https://docs.scipy.org/doc/numpy-1.15.0/user/basics.creation.html
https://jakevdp.github.io/PythonDataScienceHandbook/02.02-the-basics-of-numpy-arrays.html
I think what you are asking is the below:
w = np.array([2,1])
a = np.array([xa,ya]).T
b = np.array([xb,yb]).T
aw = np.dot(a,w)
bw = np.dot(b,w)
plt.figure(0)
plt.hist(aw,label='a',histtype='step')
plt.hist(bw,label='b',histtype='step')
plt.title('projected')
plt.legend()
add a comment |
Below links may be useful for learning numpy.
https://docs.scipy.org/doc/numpy-1.15.0/user/basics.creation.html
https://jakevdp.github.io/PythonDataScienceHandbook/02.02-the-basics-of-numpy-arrays.html
I think what you are asking is the below:
w = np.array([2,1])
a = np.array([xa,ya]).T
b = np.array([xb,yb]).T
aw = np.dot(a,w)
bw = np.dot(b,w)
plt.figure(0)
plt.hist(aw,label='a',histtype='step')
plt.hist(bw,label='b',histtype='step')
plt.title('projected')
plt.legend()
add a comment |
Below links may be useful for learning numpy.
https://docs.scipy.org/doc/numpy-1.15.0/user/basics.creation.html
https://jakevdp.github.io/PythonDataScienceHandbook/02.02-the-basics-of-numpy-arrays.html
I think what you are asking is the below:
w = np.array([2,1])
a = np.array([xa,ya]).T
b = np.array([xb,yb]).T
aw = np.dot(a,w)
bw = np.dot(b,w)
plt.figure(0)
plt.hist(aw,label='a',histtype='step')
plt.hist(bw,label='b',histtype='step')
plt.title('projected')
plt.legend()
Below links may be useful for learning numpy.
https://docs.scipy.org/doc/numpy-1.15.0/user/basics.creation.html
https://jakevdp.github.io/PythonDataScienceHandbook/02.02-the-basics-of-numpy-arrays.html
I think what you are asking is the below:
w = np.array([2,1])
a = np.array([xa,ya]).T
b = np.array([xb,yb]).T
aw = np.dot(a,w)
bw = np.dot(b,w)
plt.figure(0)
plt.hist(aw,label='a',histtype='step')
plt.hist(bw,label='b',histtype='step')
plt.title('projected')
plt.legend()
answered Nov 24 '18 at 1:07
tengteng
840721
840721
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53453957%2fconsequences-of-projecting-data-onto-lower-dimensions%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
see stats.stackexchange.com/questions/201921/…
– teng
Nov 24 '18 at 0:02
Thanks for the link it was very useful. My difficulty is how I am going to be able to break down the 2d array to be able to do the dot product as my data when np= 10 is like this. [array([ 1.63383494, 4.6541953 , 2.10788923, 2.46806161, 1.87287563, 0.76323836, 2.95160091, 1.74592451, -1.27726486, 4.22058637]), array([ 2.48245559, 1.57752103, -1.23525301, -1.76199059, -0.38459408, 1.78905969, -2.03621301, 1.23246001, 1.89331416, -0.71733151])]. I know that the first projection should come out as [11/5; 5.75/5] when taking w as [2;1]
– Michelle Abela
Nov 24 '18 at 0:54
you'll need to cast the arrays as
np.array
and for dot product, usenp.dot
.– teng
Nov 24 '18 at 0:57
1
Question has nothing to do with
machine-learning
- kindly do not spam the tag (removed).– desertnaut
Nov 24 '18 at 0:58