How to generate a data sample along a annulus (between fixed radii)?How to understand the drawbacks of K-meansSimulate a uniform distribution on a discGenerate covariance matrix with fixed values in certain cellsAdvice on comparing methods of generating random vectorsPyMC for nonparametric clustering: Dirichlet process to estimate Gaussian mixture's parameters fails to clustersampling for estimation - using random numbers - homework helpGenerate binomial sample with (pretty) exact probabilitySimulate a uniform distribution on a discGenerate synthetic data to match sample dataGenerate sample data from Gaussian mixture modelhow to compare different sets of time series dataGood choices of PRNG for uniform circular (directional) data?
Is throwing dice a stochastic or a deterministic process?
Why would a military not separate its forces into different branches?
Which "exotic salt" can lower water's freezing point by –70 °C?
Is it normal for gliders not to have attitude indicators?
weird pluperfect subjunctive in Eutropius
Drawing an hexagonal cone in TikZ 2D
Motion-trail-like lines
Is 'contemporary' ambiguous and if so is there a better word?
Sci-fi/fantasy book - ships on steel runners skating across ice sheets
Page count conversion from single to double-space for submissions
Is space itself expanding or is it just momentum from the Big Bang carrying things apart?
Should homeowners insurance cover the cost of the home?
How to pass query parameters in URL in Salesforce Summer 19 Release?
Execute command on shell command output
Which US defense organization would respond to an invasion like this?
All superlinear runtime algorithms are asymptotically equivalent to convex function?
Meaning of the (idiomatic?) expression "seghe mentali"
Why is my arithmetic with a long long int behaving this way?
Dirichlet series with a single zero
Where did Lovecraft write about Carcosa?
Why are oscilloscope input impedances so low?
Would a "Permanence" spell in 5e be overpowered?
Is the book wrong about the Nyquist Sampling Criterion?
Is any special diet an effective treatment of autism?
How to generate a data sample along a annulus (between fixed radii)?
How to understand the drawbacks of K-meansSimulate a uniform distribution on a discGenerate covariance matrix with fixed values in certain cellsAdvice on comparing methods of generating random vectorsPyMC for nonparametric clustering: Dirichlet process to estimate Gaussian mixture's parameters fails to clustersampling for estimation - using random numbers - homework helpGenerate binomial sample with (pretty) exact probabilitySimulate a uniform distribution on a discGenerate synthetic data to match sample dataGenerate sample data from Gaussian mixture modelhow to compare different sets of time series dataGood choices of PRNG for uniform circular (directional) data?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
$begingroup$
I would like to create a random data sample to test a clustering algorithm using python. One specific data sample I would like to generate consists of two non-overlapping annuluses (annuli?); however, it's okay if the inner-most annuli is a circle - as in the image below (taken from this question).
I realize that I can sample N
values of angles ti
such that 0 ≤ ti ≤ 2 pi
. Based on some reading online, I think one can generate N
samples of circular data by specifying a fixed radius r
such that xi = r cos(ti)
and yi = r sin(ti)
. Applying this reasoning to the desired annulus, I am thinking one can repeat the process for variable radii rmin
and rmax
; however, I am not sure how to proceed from this point. My thinking is to generate n
samples of radii ri
(where n
< N
, the annulus cluster is a subset of all the data) such that rmin ≤ ri ≤ rmax
; doing so necessarily means the first cluster should be the n
points within the the outer-most annulus and the second cluster should be the N-n
points within the inner-most annulus/circle.
So my questions are as follows:
1) Is my approach so far reasonable? Are there (dis)advantages to this approach, such as clustering more near centers or borders?
2) If my approach is wrong, why is it wrong and what would be a better approach?
EDIT:
The original post that serves as a potential duplicate actually shows how to sample points within a circle, not an annulus. I am concerned with the case of an annulus.
python random-generation circular-statistics
$endgroup$
|
show 5 more comments
$begingroup$
I would like to create a random data sample to test a clustering algorithm using python. One specific data sample I would like to generate consists of two non-overlapping annuluses (annuli?); however, it's okay if the inner-most annuli is a circle - as in the image below (taken from this question).
I realize that I can sample N
values of angles ti
such that 0 ≤ ti ≤ 2 pi
. Based on some reading online, I think one can generate N
samples of circular data by specifying a fixed radius r
such that xi = r cos(ti)
and yi = r sin(ti)
. Applying this reasoning to the desired annulus, I am thinking one can repeat the process for variable radii rmin
and rmax
; however, I am not sure how to proceed from this point. My thinking is to generate n
samples of radii ri
(where n
< N
, the annulus cluster is a subset of all the data) such that rmin ≤ ri ≤ rmax
; doing so necessarily means the first cluster should be the n
points within the the outer-most annulus and the second cluster should be the N-n
points within the inner-most annulus/circle.
So my questions are as follows:
1) Is my approach so far reasonable? Are there (dis)advantages to this approach, such as clustering more near centers or borders?
2) If my approach is wrong, why is it wrong and what would be a better approach?
EDIT:
The original post that serves as a potential duplicate actually shows how to sample points within a circle, not an annulus. I am concerned with the case of an annulus.
python random-generation circular-statistics
$endgroup$
$begingroup$
I'm a bit confused. You write of "two non-overlapping disks", but the innermost disk can be a "circle". Circles are one-dimensional. Your actual picture shows an annulus which is concentric with a disk. If this is what you actually want, please edit your post to clarify. Thank you!
$endgroup$
– Stephan Kolassa
45 mins ago
1
$begingroup$
Possible duplicate of Simulate a uniform distribution on a disc
$endgroup$
– Stephan Kolassa
39 mins ago
$begingroup$
That was bad terminology on my part. I edited the post to reflect that I would like to sample points within an annulus (not a disk).
$endgroup$
– allthemikeysaretaken
39 mins ago
1
$begingroup$
Your approach will suffer from the problem the poster in the proposed duplicate pointed out, with a higher density near the center than near the outer boundary. This will afflict both the annulus and the disk, but more so the disk. whuber's answer in the proposed duplicate directly gives you the disk part, and by constraining the part whererho
is generated, you get the annulus.
$endgroup$
– Stephan Kolassa
37 mins ago
$begingroup$
Is my approach of varying the radius betweenrmin
andrmax
the proper way to "constrain the part whererho
is generated"?
$endgroup$
– allthemikeysaretaken
34 mins ago
|
show 5 more comments
$begingroup$
I would like to create a random data sample to test a clustering algorithm using python. One specific data sample I would like to generate consists of two non-overlapping annuluses (annuli?); however, it's okay if the inner-most annuli is a circle - as in the image below (taken from this question).
I realize that I can sample N
values of angles ti
such that 0 ≤ ti ≤ 2 pi
. Based on some reading online, I think one can generate N
samples of circular data by specifying a fixed radius r
such that xi = r cos(ti)
and yi = r sin(ti)
. Applying this reasoning to the desired annulus, I am thinking one can repeat the process for variable radii rmin
and rmax
; however, I am not sure how to proceed from this point. My thinking is to generate n
samples of radii ri
(where n
< N
, the annulus cluster is a subset of all the data) such that rmin ≤ ri ≤ rmax
; doing so necessarily means the first cluster should be the n
points within the the outer-most annulus and the second cluster should be the N-n
points within the inner-most annulus/circle.
So my questions are as follows:
1) Is my approach so far reasonable? Are there (dis)advantages to this approach, such as clustering more near centers or borders?
2) If my approach is wrong, why is it wrong and what would be a better approach?
EDIT:
The original post that serves as a potential duplicate actually shows how to sample points within a circle, not an annulus. I am concerned with the case of an annulus.
python random-generation circular-statistics
$endgroup$
I would like to create a random data sample to test a clustering algorithm using python. One specific data sample I would like to generate consists of two non-overlapping annuluses (annuli?); however, it's okay if the inner-most annuli is a circle - as in the image below (taken from this question).
I realize that I can sample N
values of angles ti
such that 0 ≤ ti ≤ 2 pi
. Based on some reading online, I think one can generate N
samples of circular data by specifying a fixed radius r
such that xi = r cos(ti)
and yi = r sin(ti)
. Applying this reasoning to the desired annulus, I am thinking one can repeat the process for variable radii rmin
and rmax
; however, I am not sure how to proceed from this point. My thinking is to generate n
samples of radii ri
(where n
< N
, the annulus cluster is a subset of all the data) such that rmin ≤ ri ≤ rmax
; doing so necessarily means the first cluster should be the n
points within the the outer-most annulus and the second cluster should be the N-n
points within the inner-most annulus/circle.
So my questions are as follows:
1) Is my approach so far reasonable? Are there (dis)advantages to this approach, such as clustering more near centers or borders?
2) If my approach is wrong, why is it wrong and what would be a better approach?
EDIT:
The original post that serves as a potential duplicate actually shows how to sample points within a circle, not an annulus. I am concerned with the case of an annulus.
python random-generation circular-statistics
python random-generation circular-statistics
edited 35 mins ago
Stephan Kolassa
49.4k8103187
49.4k8103187
asked 48 mins ago
allthemikeysaretakenallthemikeysaretaken
134
134
$begingroup$
I'm a bit confused. You write of "two non-overlapping disks", but the innermost disk can be a "circle". Circles are one-dimensional. Your actual picture shows an annulus which is concentric with a disk. If this is what you actually want, please edit your post to clarify. Thank you!
$endgroup$
– Stephan Kolassa
45 mins ago
1
$begingroup$
Possible duplicate of Simulate a uniform distribution on a disc
$endgroup$
– Stephan Kolassa
39 mins ago
$begingroup$
That was bad terminology on my part. I edited the post to reflect that I would like to sample points within an annulus (not a disk).
$endgroup$
– allthemikeysaretaken
39 mins ago
1
$begingroup$
Your approach will suffer from the problem the poster in the proposed duplicate pointed out, with a higher density near the center than near the outer boundary. This will afflict both the annulus and the disk, but more so the disk. whuber's answer in the proposed duplicate directly gives you the disk part, and by constraining the part whererho
is generated, you get the annulus.
$endgroup$
– Stephan Kolassa
37 mins ago
$begingroup$
Is my approach of varying the radius betweenrmin
andrmax
the proper way to "constrain the part whererho
is generated"?
$endgroup$
– allthemikeysaretaken
34 mins ago
|
show 5 more comments
$begingroup$
I'm a bit confused. You write of "two non-overlapping disks", but the innermost disk can be a "circle". Circles are one-dimensional. Your actual picture shows an annulus which is concentric with a disk. If this is what you actually want, please edit your post to clarify. Thank you!
$endgroup$
– Stephan Kolassa
45 mins ago
1
$begingroup$
Possible duplicate of Simulate a uniform distribution on a disc
$endgroup$
– Stephan Kolassa
39 mins ago
$begingroup$
That was bad terminology on my part. I edited the post to reflect that I would like to sample points within an annulus (not a disk).
$endgroup$
– allthemikeysaretaken
39 mins ago
1
$begingroup$
Your approach will suffer from the problem the poster in the proposed duplicate pointed out, with a higher density near the center than near the outer boundary. This will afflict both the annulus and the disk, but more so the disk. whuber's answer in the proposed duplicate directly gives you the disk part, and by constraining the part whererho
is generated, you get the annulus.
$endgroup$
– Stephan Kolassa
37 mins ago
$begingroup$
Is my approach of varying the radius betweenrmin
andrmax
the proper way to "constrain the part whererho
is generated"?
$endgroup$
– allthemikeysaretaken
34 mins ago
$begingroup$
I'm a bit confused. You write of "two non-overlapping disks", but the innermost disk can be a "circle". Circles are one-dimensional. Your actual picture shows an annulus which is concentric with a disk. If this is what you actually want, please edit your post to clarify. Thank you!
$endgroup$
– Stephan Kolassa
45 mins ago
$begingroup$
I'm a bit confused. You write of "two non-overlapping disks", but the innermost disk can be a "circle". Circles are one-dimensional. Your actual picture shows an annulus which is concentric with a disk. If this is what you actually want, please edit your post to clarify. Thank you!
$endgroup$
– Stephan Kolassa
45 mins ago
1
1
$begingroup$
Possible duplicate of Simulate a uniform distribution on a disc
$endgroup$
– Stephan Kolassa
39 mins ago
$begingroup$
Possible duplicate of Simulate a uniform distribution on a disc
$endgroup$
– Stephan Kolassa
39 mins ago
$begingroup$
That was bad terminology on my part. I edited the post to reflect that I would like to sample points within an annulus (not a disk).
$endgroup$
– allthemikeysaretaken
39 mins ago
$begingroup$
That was bad terminology on my part. I edited the post to reflect that I would like to sample points within an annulus (not a disk).
$endgroup$
– allthemikeysaretaken
39 mins ago
1
1
$begingroup$
Your approach will suffer from the problem the poster in the proposed duplicate pointed out, with a higher density near the center than near the outer boundary. This will afflict both the annulus and the disk, but more so the disk. whuber's answer in the proposed duplicate directly gives you the disk part, and by constraining the part where
rho
is generated, you get the annulus.$endgroup$
– Stephan Kolassa
37 mins ago
$begingroup$
Your approach will suffer from the problem the poster in the proposed duplicate pointed out, with a higher density near the center than near the outer boundary. This will afflict both the annulus and the disk, but more so the disk. whuber's answer in the proposed duplicate directly gives you the disk part, and by constraining the part where
rho
is generated, you get the annulus.$endgroup$
– Stephan Kolassa
37 mins ago
$begingroup$
Is my approach of varying the radius between
rmin
and rmax
the proper way to "constrain the part where rho
is generated"?$endgroup$
– allthemikeysaretaken
34 mins ago
$begingroup$
Is my approach of varying the radius between
rmin
and rmax
the proper way to "constrain the part where rho
is generated"?$endgroup$
– allthemikeysaretaken
34 mins ago
|
show 5 more comments
1 Answer
1
active
oldest
votes
$begingroup$
Your approach will suffer from the problem the poster in the proposed duplicate pointed out, with a higher density near the center than near the outer boundary. This will afflict both the annulus and the disk, but more so the disk.
whuber's answer in the proposed duplicate directly gives you the disk part, and by constraining the part where rho
is generated, you get the annulus. Note that you need to constrain "on the square root scale".
Here is an adoption of whuber's original R code, which should be easy to translate to Python:
outer_radius <- 1
inner_radius <- 0.7
n <- 1e4
rho <- sqrt(runif(n,inner_radius^2,outer_radius^2))
theta <- runif(n, 0, 2*pi)
x <- rho * cos(theta)
y <- rho * sin(theta)
plot(x, y, pch=19, cex=0.6, col="#00000020")
$endgroup$
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "65"
;
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: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
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%2fstats.stackexchange.com%2fquestions%2f406637%2fhow-to-generate-a-data-sample-along-a-annulus-between-fixed-radii%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$
Your approach will suffer from the problem the poster in the proposed duplicate pointed out, with a higher density near the center than near the outer boundary. This will afflict both the annulus and the disk, but more so the disk.
whuber's answer in the proposed duplicate directly gives you the disk part, and by constraining the part where rho
is generated, you get the annulus. Note that you need to constrain "on the square root scale".
Here is an adoption of whuber's original R code, which should be easy to translate to Python:
outer_radius <- 1
inner_radius <- 0.7
n <- 1e4
rho <- sqrt(runif(n,inner_radius^2,outer_radius^2))
theta <- runif(n, 0, 2*pi)
x <- rho * cos(theta)
y <- rho * sin(theta)
plot(x, y, pch=19, cex=0.6, col="#00000020")
$endgroup$
add a comment |
$begingroup$
Your approach will suffer from the problem the poster in the proposed duplicate pointed out, with a higher density near the center than near the outer boundary. This will afflict both the annulus and the disk, but more so the disk.
whuber's answer in the proposed duplicate directly gives you the disk part, and by constraining the part where rho
is generated, you get the annulus. Note that you need to constrain "on the square root scale".
Here is an adoption of whuber's original R code, which should be easy to translate to Python:
outer_radius <- 1
inner_radius <- 0.7
n <- 1e4
rho <- sqrt(runif(n,inner_radius^2,outer_radius^2))
theta <- runif(n, 0, 2*pi)
x <- rho * cos(theta)
y <- rho * sin(theta)
plot(x, y, pch=19, cex=0.6, col="#00000020")
$endgroup$
add a comment |
$begingroup$
Your approach will suffer from the problem the poster in the proposed duplicate pointed out, with a higher density near the center than near the outer boundary. This will afflict both the annulus and the disk, but more so the disk.
whuber's answer in the proposed duplicate directly gives you the disk part, and by constraining the part where rho
is generated, you get the annulus. Note that you need to constrain "on the square root scale".
Here is an adoption of whuber's original R code, which should be easy to translate to Python:
outer_radius <- 1
inner_radius <- 0.7
n <- 1e4
rho <- sqrt(runif(n,inner_radius^2,outer_radius^2))
theta <- runif(n, 0, 2*pi)
x <- rho * cos(theta)
y <- rho * sin(theta)
plot(x, y, pch=19, cex=0.6, col="#00000020")
$endgroup$
Your approach will suffer from the problem the poster in the proposed duplicate pointed out, with a higher density near the center than near the outer boundary. This will afflict both the annulus and the disk, but more so the disk.
whuber's answer in the proposed duplicate directly gives you the disk part, and by constraining the part where rho
is generated, you get the annulus. Note that you need to constrain "on the square root scale".
Here is an adoption of whuber's original R code, which should be easy to translate to Python:
outer_radius <- 1
inner_radius <- 0.7
n <- 1e4
rho <- sqrt(runif(n,inner_radius^2,outer_radius^2))
theta <- runif(n, 0, 2*pi)
x <- rho * cos(theta)
y <- rho * sin(theta)
plot(x, y, pch=19, cex=0.6, col="#00000020")
edited 4 mins ago
answered 31 mins ago
Stephan KolassaStephan Kolassa
49.4k8103187
49.4k8103187
add a comment |
add a comment |
Thanks for contributing an answer to Cross Validated!
- 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%2fstats.stackexchange.com%2fquestions%2f406637%2fhow-to-generate-a-data-sample-along-a-annulus-between-fixed-radii%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$
I'm a bit confused. You write of "two non-overlapping disks", but the innermost disk can be a "circle". Circles are one-dimensional. Your actual picture shows an annulus which is concentric with a disk. If this is what you actually want, please edit your post to clarify. Thank you!
$endgroup$
– Stephan Kolassa
45 mins ago
1
$begingroup$
Possible duplicate of Simulate a uniform distribution on a disc
$endgroup$
– Stephan Kolassa
39 mins ago
$begingroup$
That was bad terminology on my part. I edited the post to reflect that I would like to sample points within an annulus (not a disk).
$endgroup$
– allthemikeysaretaken
39 mins ago
1
$begingroup$
Your approach will suffer from the problem the poster in the proposed duplicate pointed out, with a higher density near the center than near the outer boundary. This will afflict both the annulus and the disk, but more so the disk. whuber's answer in the proposed duplicate directly gives you the disk part, and by constraining the part where
rho
is generated, you get the annulus.$endgroup$
– Stephan Kolassa
37 mins ago
$begingroup$
Is my approach of varying the radius between
rmin
andrmax
the proper way to "constrain the part whererho
is generated"?$endgroup$
– allthemikeysaretaken
34 mins ago