Finding positions of minimum values in listList manipulation: position & max value combinationHow to...
How can I support myself financially as a 17 year old with a loan?
I'm in your subnets, golfing your code
Using column size much larger than necessary
Where can I go to avoid planes overhead?
Hyperlink on red background
Why did the Apollo 13 crew extend the LM landing gear?
Building a list of products from the elements in another list
Does a card have a keyword if it has the same effect as said keyword?
Out of scope work duties and resignation
How should I tell my manager I'm not paying for an optional after work event I'm not going to?
Would glacier 'trees' be plausible?
Have I damaged my car by attempting to reverse with hand/park brake up?
What was the first instance of a "planet eater" in sci-fi?
What are the advantages of luxury car brands like Acura/Lexus over their sibling non-luxury brands Honda/Toyota?
What is the difference between 反日 and 日本たたき?
Will 700 more planes a day fly because of the Heathrow expansion?
Randomness of Python's random
Send iMessage from Firefox
How do I overfit?
I have a unique character that I'm having a problem writing. He's a virus!
Upside-Down Pyramid Addition...REVERSED!
How do LIGO and VIRGO know that a gravitational wave has its origin in a neutron star or a black hole?
Why do money exchangers give different rates to different bills?
Set collection doesn't always enforce uniqueness with the Date datatype? Does the following example seem correct?
Finding positions of minimum values in list
List manipulation: position & max value combinationHow to efficiently find positions of duplicates?Finding elements from a sparse matrixInsert at specific resulting positions?Insert at specific resulting positions in multidimensional list?How can I get a list of the positions of the running minima in a list?Add values from a list, at positions from a list, to a matrixPositions of elements in a listAssemble rule replacement from pairs of positionsList positions without bracketsFinding the minimum value in a column and extracting the row where the minimum value placed there
$begingroup$
I would like to find the positions of multiple occurrences of a minimum value in a list. For instance, for the list {1, 2, 1, 3}, I want to obtain the two positions for the occurrences of the number 1.
MinimalBy[{1, 2, 1, 3}, id (x)] gives me these occurrences, but not the positions.
list-manipulation
$endgroup$
add a comment |
$begingroup$
I would like to find the positions of multiple occurrences of a minimum value in a list. For instance, for the list {1, 2, 1, 3}, I want to obtain the two positions for the occurrences of the number 1.
MinimalBy[{1, 2, 1, 3}, id (x)] gives me these occurrences, but not the positions.
list-manipulation
$endgroup$
$begingroup$
MinimalBy[Range@Length@list, list[[#]] &]
?
$endgroup$
– Michael E2
3 hours ago
$begingroup$
Or modifying this answer:minpos[a_] := SparseArray[UnitStep[# - a]]["AdjacencyLists"] &@Min@a
and thenminpos[list]
.
$endgroup$
– Michael E2
3 hours ago
$begingroup$
Possible duplicate: mathematica.stackexchange.com/questions/40231/…
$endgroup$
– Michael E2
3 hours ago
add a comment |
$begingroup$
I would like to find the positions of multiple occurrences of a minimum value in a list. For instance, for the list {1, 2, 1, 3}, I want to obtain the two positions for the occurrences of the number 1.
MinimalBy[{1, 2, 1, 3}, id (x)] gives me these occurrences, but not the positions.
list-manipulation
$endgroup$
I would like to find the positions of multiple occurrences of a minimum value in a list. For instance, for the list {1, 2, 1, 3}, I want to obtain the two positions for the occurrences of the number 1.
MinimalBy[{1, 2, 1, 3}, id (x)] gives me these occurrences, but not the positions.
list-manipulation
list-manipulation
asked 3 hours ago
MikeMike
926
926
$begingroup$
MinimalBy[Range@Length@list, list[[#]] &]
?
$endgroup$
– Michael E2
3 hours ago
$begingroup$
Or modifying this answer:minpos[a_] := SparseArray[UnitStep[# - a]]["AdjacencyLists"] &@Min@a
and thenminpos[list]
.
$endgroup$
– Michael E2
3 hours ago
$begingroup$
Possible duplicate: mathematica.stackexchange.com/questions/40231/…
$endgroup$
– Michael E2
3 hours ago
add a comment |
$begingroup$
MinimalBy[Range@Length@list, list[[#]] &]
?
$endgroup$
– Michael E2
3 hours ago
$begingroup$
Or modifying this answer:minpos[a_] := SparseArray[UnitStep[# - a]]["AdjacencyLists"] &@Min@a
and thenminpos[list]
.
$endgroup$
– Michael E2
3 hours ago
$begingroup$
Possible duplicate: mathematica.stackexchange.com/questions/40231/…
$endgroup$
– Michael E2
3 hours ago
$begingroup$
MinimalBy[Range@Length@list, list[[#]] &]
?$endgroup$
– Michael E2
3 hours ago
$begingroup$
MinimalBy[Range@Length@list, list[[#]] &]
?$endgroup$
– Michael E2
3 hours ago
$begingroup$
Or modifying this answer:
minpos[a_] := SparseArray[UnitStep[# - a]]["AdjacencyLists"] &@Min@a
and then minpos[list]
.$endgroup$
– Michael E2
3 hours ago
$begingroup$
Or modifying this answer:
minpos[a_] := SparseArray[UnitStep[# - a]]["AdjacencyLists"] &@Min@a
and then minpos[list]
.$endgroup$
– Michael E2
3 hours ago
$begingroup$
Possible duplicate: mathematica.stackexchange.com/questions/40231/…
$endgroup$
– Michael E2
3 hours ago
$begingroup$
Possible duplicate: mathematica.stackexchange.com/questions/40231/…
$endgroup$
– Michael E2
3 hours ago
add a comment |
1 Answer
1
active
oldest
votes
$begingroup$
lst = {1, 2, 1, 3};
Random`Private`PositionsOf[lst, Min @ lst]
{1, 3}
Also
Flatten@Position[lst, Min @ lst]
{1, 3}
$endgroup$
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "387"
};
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%2fmathematica.stackexchange.com%2fquestions%2f197492%2ffinding-positions-of-minimum-values-in-list%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$
lst = {1, 2, 1, 3};
Random`Private`PositionsOf[lst, Min @ lst]
{1, 3}
Also
Flatten@Position[lst, Min @ lst]
{1, 3}
$endgroup$
add a comment |
$begingroup$
lst = {1, 2, 1, 3};
Random`Private`PositionsOf[lst, Min @ lst]
{1, 3}
Also
Flatten@Position[lst, Min @ lst]
{1, 3}
$endgroup$
add a comment |
$begingroup$
lst = {1, 2, 1, 3};
Random`Private`PositionsOf[lst, Min @ lst]
{1, 3}
Also
Flatten@Position[lst, Min @ lst]
{1, 3}
$endgroup$
lst = {1, 2, 1, 3};
Random`Private`PositionsOf[lst, Min @ lst]
{1, 3}
Also
Flatten@Position[lst, Min @ lst]
{1, 3}
edited 2 hours ago
answered 2 hours ago
kglrkglr
190k10209427
190k10209427
add a comment |
add a comment |
Thanks for contributing an answer to Mathematica 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%2fmathematica.stackexchange.com%2fquestions%2f197492%2ffinding-positions-of-minimum-values-in-list%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$
MinimalBy[Range@Length@list, list[[#]] &]
?$endgroup$
– Michael E2
3 hours ago
$begingroup$
Or modifying this answer:
minpos[a_] := SparseArray[UnitStep[# - a]]["AdjacencyLists"] &@Min@a
and thenminpos[list]
.$endgroup$
– Michael E2
3 hours ago
$begingroup$
Possible duplicate: mathematica.stackexchange.com/questions/40231/…
$endgroup$
– Michael E2
3 hours ago