How to apply this linear transformation $(x:=2x+1)$ on R-sequence result to generate points in range...
$begingroup$
I want to used R-sequence proposed by Martin Roberts to generate points in range [-1,1].
In this post, Martin Roberts mentioned that:
... to convert to a range of [-1,1], simply apply the linear
transformation x:=2x+1. The result is
(-0.361655, -0.657913, -0.900599)
(-0.72331, 0.684174, 0.198802)
(0.915035, 0.0262616, -0.701797)
(0.55338, -0.631651, 0.397604)
(0.191725, 0.710436, -0.502995),...
I am not specialist in math, I just want to know how to apply this transformation to generate points in range [-1,1]?
and in which part of the provided code?
This code generates points in range [0,1]
# Use Newton-Rhapson-Method
def gamma(d):
x=1.0000
for i in range(20):
x = x-(pow(x,d+1)-x-1)/((d+1)*pow(x,d)-1)
return x
d=3
n=5
g = gamma(d)
alpha = np.zeros(d)
for j in range(d):
alpha[j] = pow(1/g,j+1) %1
z = np.zeros((n, d))
for i in range(n):
z = (0.5 + alpha*(i+1)) %1
print(z)
The result is:
(0.319173, 0.171044, 0.0497005)
(0.138345, 0.842087, 0.599401)
(0.957518, 0.513131, 0.149101)
(0.77669, 0.184174, 0.698802)
(0.595863, 0.855218, 0.248502) ...
How to apply this linear transformation x:=2x+1
to get this result:
(-0.361655, -0.657913, -0.900599)
(-0.72331, 0.684174, 0.198802)
(0.915035, 0.0262616, -0.701797)
(0.55338, -0.631651, 0.397604)
(0.191725, 0.710436, -0.502995),...
linear-transformations python
$endgroup$
add a comment |
$begingroup$
I want to used R-sequence proposed by Martin Roberts to generate points in range [-1,1].
In this post, Martin Roberts mentioned that:
... to convert to a range of [-1,1], simply apply the linear
transformation x:=2x+1. The result is
(-0.361655, -0.657913, -0.900599)
(-0.72331, 0.684174, 0.198802)
(0.915035, 0.0262616, -0.701797)
(0.55338, -0.631651, 0.397604)
(0.191725, 0.710436, -0.502995),...
I am not specialist in math, I just want to know how to apply this transformation to generate points in range [-1,1]?
and in which part of the provided code?
This code generates points in range [0,1]
# Use Newton-Rhapson-Method
def gamma(d):
x=1.0000
for i in range(20):
x = x-(pow(x,d+1)-x-1)/((d+1)*pow(x,d)-1)
return x
d=3
n=5
g = gamma(d)
alpha = np.zeros(d)
for j in range(d):
alpha[j] = pow(1/g,j+1) %1
z = np.zeros((n, d))
for i in range(n):
z = (0.5 + alpha*(i+1)) %1
print(z)
The result is:
(0.319173, 0.171044, 0.0497005)
(0.138345, 0.842087, 0.599401)
(0.957518, 0.513131, 0.149101)
(0.77669, 0.184174, 0.698802)
(0.595863, 0.855218, 0.248502) ...
How to apply this linear transformation x:=2x+1
to get this result:
(-0.361655, -0.657913, -0.900599)
(-0.72331, 0.684174, 0.198802)
(0.915035, 0.0262616, -0.701797)
(0.55338, -0.631651, 0.397604)
(0.191725, 0.710436, -0.502995),...
linear-transformations python
$endgroup$
$begingroup$
Please try to make the titles of your questions more informative. For example, Why does $a<b$ imply $a+c<b+c$? is much more useful for other users than A question about inequality. From How can I ask a good question?: Make your title as descriptive as possible. In many cases one can actually phrase the title as the question, at least in such a way so as to be comprehensible to an expert reader. You can find more tips for choosing a good title here.
$endgroup$
– Shaun
Dec 8 '18 at 11:56
add a comment |
$begingroup$
I want to used R-sequence proposed by Martin Roberts to generate points in range [-1,1].
In this post, Martin Roberts mentioned that:
... to convert to a range of [-1,1], simply apply the linear
transformation x:=2x+1. The result is
(-0.361655, -0.657913, -0.900599)
(-0.72331, 0.684174, 0.198802)
(0.915035, 0.0262616, -0.701797)
(0.55338, -0.631651, 0.397604)
(0.191725, 0.710436, -0.502995),...
I am not specialist in math, I just want to know how to apply this transformation to generate points in range [-1,1]?
and in which part of the provided code?
This code generates points in range [0,1]
# Use Newton-Rhapson-Method
def gamma(d):
x=1.0000
for i in range(20):
x = x-(pow(x,d+1)-x-1)/((d+1)*pow(x,d)-1)
return x
d=3
n=5
g = gamma(d)
alpha = np.zeros(d)
for j in range(d):
alpha[j] = pow(1/g,j+1) %1
z = np.zeros((n, d))
for i in range(n):
z = (0.5 + alpha*(i+1)) %1
print(z)
The result is:
(0.319173, 0.171044, 0.0497005)
(0.138345, 0.842087, 0.599401)
(0.957518, 0.513131, 0.149101)
(0.77669, 0.184174, 0.698802)
(0.595863, 0.855218, 0.248502) ...
How to apply this linear transformation x:=2x+1
to get this result:
(-0.361655, -0.657913, -0.900599)
(-0.72331, 0.684174, 0.198802)
(0.915035, 0.0262616, -0.701797)
(0.55338, -0.631651, 0.397604)
(0.191725, 0.710436, -0.502995),...
linear-transformations python
$endgroup$
I want to used R-sequence proposed by Martin Roberts to generate points in range [-1,1].
In this post, Martin Roberts mentioned that:
... to convert to a range of [-1,1], simply apply the linear
transformation x:=2x+1. The result is
(-0.361655, -0.657913, -0.900599)
(-0.72331, 0.684174, 0.198802)
(0.915035, 0.0262616, -0.701797)
(0.55338, -0.631651, 0.397604)
(0.191725, 0.710436, -0.502995),...
I am not specialist in math, I just want to know how to apply this transformation to generate points in range [-1,1]?
and in which part of the provided code?
This code generates points in range [0,1]
# Use Newton-Rhapson-Method
def gamma(d):
x=1.0000
for i in range(20):
x = x-(pow(x,d+1)-x-1)/((d+1)*pow(x,d)-1)
return x
d=3
n=5
g = gamma(d)
alpha = np.zeros(d)
for j in range(d):
alpha[j] = pow(1/g,j+1) %1
z = np.zeros((n, d))
for i in range(n):
z = (0.5 + alpha*(i+1)) %1
print(z)
The result is:
(0.319173, 0.171044, 0.0497005)
(0.138345, 0.842087, 0.599401)
(0.957518, 0.513131, 0.149101)
(0.77669, 0.184174, 0.698802)
(0.595863, 0.855218, 0.248502) ...
How to apply this linear transformation x:=2x+1
to get this result:
(-0.361655, -0.657913, -0.900599)
(-0.72331, 0.684174, 0.198802)
(0.915035, 0.0262616, -0.701797)
(0.55338, -0.631651, 0.397604)
(0.191725, 0.710436, -0.502995),...
linear-transformations python
linear-transformations python
edited Dec 8 '18 at 15:20
Key Flex
8,58761233
8,58761233
asked Dec 8 '18 at 11:48
user10608907user10608907
32
32
$begingroup$
Please try to make the titles of your questions more informative. For example, Why does $a<b$ imply $a+c<b+c$? is much more useful for other users than A question about inequality. From How can I ask a good question?: Make your title as descriptive as possible. In many cases one can actually phrase the title as the question, at least in such a way so as to be comprehensible to an expert reader. You can find more tips for choosing a good title here.
$endgroup$
– Shaun
Dec 8 '18 at 11:56
add a comment |
$begingroup$
Please try to make the titles of your questions more informative. For example, Why does $a<b$ imply $a+c<b+c$? is much more useful for other users than A question about inequality. From How can I ask a good question?: Make your title as descriptive as possible. In many cases one can actually phrase the title as the question, at least in such a way so as to be comprehensible to an expert reader. You can find more tips for choosing a good title here.
$endgroup$
– Shaun
Dec 8 '18 at 11:56
$begingroup$
Please try to make the titles of your questions more informative. For example, Why does $a<b$ imply $a+c<b+c$? is much more useful for other users than A question about inequality. From How can I ask a good question?: Make your title as descriptive as possible. In many cases one can actually phrase the title as the question, at least in such a way so as to be comprehensible to an expert reader. You can find more tips for choosing a good title here.
$endgroup$
– Shaun
Dec 8 '18 at 11:56
$begingroup$
Please try to make the titles of your questions more informative. For example, Why does $a<b$ imply $a+c<b+c$? is much more useful for other users than A question about inequality. From How can I ask a good question?: Make your title as descriptive as possible. In many cases one can actually phrase the title as the question, at least in such a way so as to be comprehensible to an expert reader. You can find more tips for choosing a good title here.
$endgroup$
– Shaun
Dec 8 '18 at 11:56
add a comment |
1 Answer
1
active
oldest
votes
$begingroup$
The linear transformation seems to be false. You need
$f: begin{cases}
[0, 1] &to [-1, 1] \
x &mapsto 2x mathop{mathbf{-}} 1
end{cases}$
Simply apply the linear transformation (a function!) to every element in the vector. Since I have no python installed, the following source code to do this is not tested:
# ...
for i in range(n):
for j in range(d):
z[i][j] = 2 * z[i][j] - 1
print(z)
EDIT: Another method would use list comprehension, something like [[2 * z[i][j] - 1 for j in range(d)] for i in range(n)]
(again untested). But Python does not operate on matrices implicitly like Mathematica and Octave do.
$endgroup$
$begingroup$
it is working. Would you please give examples for another methods for transformation? Thank you
$endgroup$
– user10608907
Dec 8 '18 at 12:45
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
return StackExchange.using("mathjaxEditing", function () {
StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
});
});
}, "mathjax-editing");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "69"
};
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
},
noCode: 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%2fmath.stackexchange.com%2fquestions%2f3031013%2fhow-to-apply-this-linear-transformation-x-2x1-on-r-sequence-result-to-gene%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
$begingroup$
The linear transformation seems to be false. You need
$f: begin{cases}
[0, 1] &to [-1, 1] \
x &mapsto 2x mathop{mathbf{-}} 1
end{cases}$
Simply apply the linear transformation (a function!) to every element in the vector. Since I have no python installed, the following source code to do this is not tested:
# ...
for i in range(n):
for j in range(d):
z[i][j] = 2 * z[i][j] - 1
print(z)
EDIT: Another method would use list comprehension, something like [[2 * z[i][j] - 1 for j in range(d)] for i in range(n)]
(again untested). But Python does not operate on matrices implicitly like Mathematica and Octave do.
$endgroup$
$begingroup$
it is working. Would you please give examples for another methods for transformation? Thank you
$endgroup$
– user10608907
Dec 8 '18 at 12:45
add a comment |
$begingroup$
The linear transformation seems to be false. You need
$f: begin{cases}
[0, 1] &to [-1, 1] \
x &mapsto 2x mathop{mathbf{-}} 1
end{cases}$
Simply apply the linear transformation (a function!) to every element in the vector. Since I have no python installed, the following source code to do this is not tested:
# ...
for i in range(n):
for j in range(d):
z[i][j] = 2 * z[i][j] - 1
print(z)
EDIT: Another method would use list comprehension, something like [[2 * z[i][j] - 1 for j in range(d)] for i in range(n)]
(again untested). But Python does not operate on matrices implicitly like Mathematica and Octave do.
$endgroup$
$begingroup$
it is working. Would you please give examples for another methods for transformation? Thank you
$endgroup$
– user10608907
Dec 8 '18 at 12:45
add a comment |
$begingroup$
The linear transformation seems to be false. You need
$f: begin{cases}
[0, 1] &to [-1, 1] \
x &mapsto 2x mathop{mathbf{-}} 1
end{cases}$
Simply apply the linear transformation (a function!) to every element in the vector. Since I have no python installed, the following source code to do this is not tested:
# ...
for i in range(n):
for j in range(d):
z[i][j] = 2 * z[i][j] - 1
print(z)
EDIT: Another method would use list comprehension, something like [[2 * z[i][j] - 1 for j in range(d)] for i in range(n)]
(again untested). But Python does not operate on matrices implicitly like Mathematica and Octave do.
$endgroup$
The linear transformation seems to be false. You need
$f: begin{cases}
[0, 1] &to [-1, 1] \
x &mapsto 2x mathop{mathbf{-}} 1
end{cases}$
Simply apply the linear transformation (a function!) to every element in the vector. Since I have no python installed, the following source code to do this is not tested:
# ...
for i in range(n):
for j in range(d):
z[i][j] = 2 * z[i][j] - 1
print(z)
EDIT: Another method would use list comprehension, something like [[2 * z[i][j] - 1 for j in range(d)] for i in range(n)]
(again untested). But Python does not operate on matrices implicitly like Mathematica and Octave do.
edited Dec 8 '18 at 15:16
answered Dec 8 '18 at 12:13
user7427029user7427029
1207
1207
$begingroup$
it is working. Would you please give examples for another methods for transformation? Thank you
$endgroup$
– user10608907
Dec 8 '18 at 12:45
add a comment |
$begingroup$
it is working. Would you please give examples for another methods for transformation? Thank you
$endgroup$
– user10608907
Dec 8 '18 at 12:45
$begingroup$
it is working. Would you please give examples for another methods for transformation? Thank you
$endgroup$
– user10608907
Dec 8 '18 at 12:45
$begingroup$
it is working. Would you please give examples for another methods for transformation? Thank you
$endgroup$
– user10608907
Dec 8 '18 at 12:45
add a comment |
Thanks for contributing an answer to Mathematics Stack Exchange!
- 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.
Use MathJax to format equations. MathJax reference.
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%2fmath.stackexchange.com%2fquestions%2f3031013%2fhow-to-apply-this-linear-transformation-x-2x1-on-r-sequence-result-to-gene%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
$begingroup$
Please try to make the titles of your questions more informative. For example, Why does $a<b$ imply $a+c<b+c$? is much more useful for other users than A question about inequality. From How can I ask a good question?: Make your title as descriptive as possible. In many cases one can actually phrase the title as the question, at least in such a way so as to be comprehensible to an expert reader. You can find more tips for choosing a good title here.
$endgroup$
– Shaun
Dec 8 '18 at 11:56