X
PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 16 Jan 2019 10:39 AM by  Ben Castellani
Argmin
 1 Replies
Sort:
You are not authorized to post a reply.
Author Messages

Hugo De Lemos



New Member


Posts:
New Member


--
14 Jan 2019 03:45 AM
    Hi,

    I would like to calculate the argument of the minimum or Argmin of a set of multivariate points. The Argmin should return the indices of the minimum values along an axis.

    Assuming I have a multidimensional array data = FLOAT[500, 300, 10]

    xaxis = 500
    yaxiz = 300
    observations = 10

    Calculating argmin for a one-dimensional array could be done as follows:

    a = [0, 1, 2, 3, 4, 5, 6, 7, 8]
    argmin = SORT(MIN(a, DIMENSION = 1))
    argmin = 0

    How would this be achieved for a multi-dimensional array of the size 500, 300, 10.

    Regards
    Hugo

    Ben Castellani



    Basic Member


    Posts:130
    Basic Member


    --
    16 Jan 2019 10:39 AM
    From my understanding, ARGMIN is just the value of the independent variable(s) that correspond to the global minimum in the dependent variable. Your one-dimensional example is thus wrong. No matter which location you place the "0", your formula always returns 0.

    a = [1, 2, 3, 4, 0, 6, 7, 8]
    argmin = SORT(MIN(a, DIMENSION = 1))
    argmin = 0

    The correct formula for ARGMIN would be as follows, which by the way will work for N dimensions:

    argmin = array_indices(a,where(a EQ min(a)))

    You can test this with a sample 2D array:

    a = [[5, 1, 2, 3, 1, 5, 6, 7, 8],[15, 11, 12, 13,11, 15, 16, 17, 18],[[25, 21, 22, 23,21, 25, 26, 27,28]]]
    argmin = array_indices(a,where(a EQ min(a)))
    print, argmin
    1 0
    4 0

    In my original array, the minimum value (1) occurs twice. Once in [Column 1, Row 0] and also at [Column 4, Row 0].

    Hope this helps.

    You are not authorized to post a reply.