Questions tagged [min]

Minimum value. Smallest, tiniest, least.

Min() is a math library function available in many programming environments which returns the entity of smallest value from two or more candidate values.

Do not use for:

  • Question about minimal value of type (Long.MIN_VALUE, Integer.MIN_VALUE etc.)

Examples:

SQL

SQL MIN() function is one of aggregate functions. It returns the smallest value of column.
Example:

SELECT MIN(column_name) FROM table_name;

Python

In Python, the native min function identifies the smallest element of a set (e.g., a list):

>> min([1, 2, 3])
1

Java

In Java we can use java.lang.Math class to compute minimum value of two arguments. Example:

int minElement = Math.min(x, y);

To compute minimum element in collection we can use ,min() method from java.util.Collections class:

int minElement = Collections.min(list);

Ruby

In Ruby to compute minimum element of collection we simply use min function:

[4,7].min

Clojure

In Clojure we use min function in following way:

(min 1 2 3 4)

In above code `min' is function name and numbers 1..4 are arguments passed to it.
Or if we have list defined:

def myList [1 2 3 4]

then we can compute min this way:

(apply min myList)

R

In R we have function min.

x <- c(1, 2, 3)
y <- c(4, 5)
z <- c(0, NA)
min(x)
min(y)
min(z)
min(z, na.rm = TRUE)
min(x, y, z, na.rm = TRUE)  ## as same as min(c(x, y, z), na.rm = TRUE)
3013 questions
0
votes
1 answer

Get point with minimum x from 2D numpy array of points

This code snippet: a = np.array([[1, 2], [0, 4], [3, 5]]) print(a[np.argmin(a[:, 0])]) prints coordinates of the point with minimum X coordinate from array a of points [x, y]: [0 4] Is there a more direct Numpy function than a[np.argmin(a[:, 0])]…
Paul Jurczak
  • 7,008
  • 3
  • 47
  • 72
0
votes
1 answer

Find min() value in List is not returning the right result

I'm trying to find minimum value in an ArrayList which contains about one million rows of data. This is how far I worked it out but it is always returning wrong min() value in List. I tried min() method of DoubleStream, Collections and Arrays but…
James
  • 1
  • 2
0
votes
4 answers

How to get the second smallest value in pandas series (pandas.Series.min)?

Some of my data contains "0.0" as a placeholder for empty values. I need to grab the smallest value that's not "0.0". It would be easy in excel since it will ask you which smallest value you want, but it doesn't look like pandas.Series.min has the…
lmac
  • 117
  • 8
0
votes
4 answers

Create a table from dataframe column values mean and standard deviation in R

I am new to R so no idea about the code. I have two data frames. One dataframe looks like…
user17416440
0
votes
1 answer

Ignore NA values when using MIN function of "apply"

I am trying to get a column made up of the minimum values from other specified columns in which NA values are ignored. When I do this: foo = data.frame(A = c(1, 2, 3, NA), B = c(3, NA, 2, NA), C = c(NA, 1, 2, 3)) foo$MIN = apply(foo[c("A", "B")], 1,…
0
votes
1 answer

group by ID and filter by condition - if something then mark them as something else

On my query right now I'm receiving and ID that can be repeated and the status, so I want to group by ID but if any of the rows has status ACTIVE then it should appear ACTIVE. I have something like this: And I want to end up with something like…
Tonino Fernandez
  • 441
  • 4
  • 12
0
votes
3 answers

I have a problem in the position of the maximum and minimum, check the program below please

#include #include int main () { int MIN,MAX,j,k; int e,i,T[100],f=0; \ Here to enter the dimension of my array printf("Entrez la dimension de votre tableau ne depasser pas 100 :…
0
votes
1 answer

How to get least value from table in sql

I am getting the top value and least value from table,table accepting the nulls also.i am able to get the top value but not the low value. This is my table data: PostBidId UserId PostId …
bharathi m
  • 11
  • 2
  • 7
0
votes
2 answers

No output from c++ loop

Recently I coded a program to choose k numbers from the string in order from left to right to print out the number that has k characters and the smallest that can be made from the string itself for example : Input : 3 89678982 Output: 672 Then my…
0
votes
3 answers

Google Sheets - Query Minimum value for each month

I am trying to fetch the minimum value for each month in a dataset like this: 1/3/2000 15:30:00 1592.2 1/4/2000 15:30:00 1638.7 1/5/2000 15:30:00 1595.8 1/6/2000 15:30:00 1617.6 1/7/2000 15:30:00 1613.3 1/10/2000 15:30:00 …
user2761431
  • 925
  • 2
  • 11
  • 26
0
votes
1 answer

How to use argmin() and find minimum value from array

I'm new to python so the code may not be the best. I'm trying to find the minimum Total Cost (TotalC) and the corresponding m,k and xM values that go with this minimum cost. I'm not sure how to do this. I have tried using min(TotalC) however this…
KMR
  • 15
  • 3
0
votes
1 answer

select the min value of a id from other table

I want to select the min value of a id from other table here my table1 id grades 1 1 2 2 1 3 1 4 2 5 my table2 id name 1 andy 2 lucy 3 kevin I tried this select table2.id, name, min(table1.grades) as grade from…
leo
  • 3
  • 2
0
votes
2 answers

why is my code not finding the index in my array?

I've put my code below. Basically, I find the lowest number of an element in the array, and I also want it to find the index of the lowest element. It finds the index with a fairly low amount of elements, but for some reason it sometimes just seems…
user17660286
0
votes
1 answer

Visual Studio datagridview having problem to get minumum value of cells and the other cells to a text box

I face problem while tying to get min value from datagridview and output to a label.text/textbox.text. This is my design Dim max As Integer Dim maxname As String = "" Dim maxgd As String = "" Dim maxvalue As String = "" For i =…
Eugene Tan
  • 11
  • 2
0
votes
0 answers

the DOM doesn't work with me when I try min and max and it show NaN

when I run it gave me a NaN and I have tried many times. here's the javascript file and HTML file javascrit file: function MinButton(){ var td1Text = document.getElementById("td1").textContent; // Get array of numbers from text var…
Zahra Alameri
  • 11
  • 1
  • 3
1 2 3
99
100