Questions tagged [argmax]

arguments of the maxima: given a function of some arguments, argmax stands for the values of the arguments that maximizes the function.

Case 1

Here we consider a function f that maps from a limited set.

Say,

f(x) := {13, 42, 1981, 9, 11, 0},

so f(x = 1) = 13,and f(x = 2) = 42, so on.

It is easy to see here that the value of x that maximizes the function f is 3; that is f(x = 3) = 1981 is the highest values. Thus, argmax of f(x) is x = 3.

In R

f = c(13, 42, 1981, 9, 11, 0)
which.max(f)
# 3

Case 2

Here we consider a function of a continues variable.

Consider

f(x) = x(4 - x)

for this function the argmax is x = 2. That is the highest value of f(x) is 4 which corresponds to x = 2.

In R, we can use the optimize function for this to find the argmax of f.

f <- function(x) {
     x*(4 - x)
}

optimize(f, interval = c(-100, 100), maximum = TRUE)
# $maximum
# [1] 2
#
#$objective
#[1] 4
170 questions
-1
votes
2 answers

Extract and compare values of a list depending on their arguments which come from another list

We have 2 lists of 10 values each one, as you can see an example here: Index list: [0, 5, 5, 6, 0, 1, 1, 8, 9, 9] Index list Mfccs : [0.640495, 0.4822588, 0.6523488, 0.74474275, 0.5423001, 0.85711163, 0.724612, 0.5099624, 0.9696293, 0.97258127] The…
A Khe
  • 73
  • 7
-1
votes
1 answer

using the np.argmax function with python ans pandas

im trying some excercises using python pandas module and map and np.argmap functions with a data base . this is my code : import pandas as pd pd.set_option('max_rows', 5) import numpy as np from…
-1
votes
1 answer

Using argmax to find largest number in a list of elements

Ok so I define 3 lists: (define mylist '((pause 5 5 5)(note 3 4 5)(pause 3 4 4))) (define myseqlist '(sequential-music-element (note 5 5 5) (note 4 3 4) (note 5 3 4))) (define myparlist '(parallel-music-element (note 5 2 5) (note 4 2 4) (note 5 3…
crystyxn
  • 1,411
  • 4
  • 27
  • 59
-2
votes
1 answer

Use numpy argmax to find the first occurrence of value greater than 5 in the following array: arr = range(2, 20)

Use numpy argmax to find the first occurrence of value greater than 5 in the following array: arr = range(2, 20)
-2
votes
2 answers

I need to speed up my code, Also I need to use += i , for sure:for i in nums: sumof += i, its peivets memory block

I try to convert my argmax into array.index(max(array)) I will appreciate any help. I need to speed up my code. This code is only for one picture, I will have around 20 pictures in a min. So that's why I try to make it faster as possible. import…
1 2 3
11
12