Questions tagged [minimum]

Minimum refers to the value in a collection of values that is the least or smallest.

In mathematics, the minimum of a function is the smallest value that the function takes at a point either within a given neighborhood (local or relative minimum) or on the function domain in its entirety (absolute minimum).

Examples

Python

>> import numpy as np
>> np.min([0, 1, 2])
0

See also

1056 questions
30
votes
15 answers

Finding two non-subsequent elements in array which sum is minimal

Intro: As far as I could search, this question wasn't asked in SO yet. This is an interview question. I am not even specifically looking for a code solution, any algorithm/pseudocode will work. The problem: Given an integer array int[] A and its…
Idos
  • 15,053
  • 14
  • 60
  • 75
28
votes
2 answers

How can I decide what to put in my CMakeList.txt's cmake_minimum_required call?

I want to define a minimum version to CMake with "cmake_minimum_required" facility. I have seen that some project set minimum version 2.8 some others set 3.0 or 3.2. What's a useful way to decide what to put in my project's call to…
mustafagonul
  • 1,139
  • 1
  • 15
  • 32
28
votes
7 answers

Requiring at least one element in java variable argument list

In this code construct: public MyClass(Integer... numbers) { do_something_with(numbers[]); } is it possible to require that numbers contains at least one entry in such a way, that this is checked at compile-time? (At run-time, of course, I can…
Markus A.
  • 12,349
  • 8
  • 52
  • 116
27
votes
4 answers

In C++, is it better to cap a value using std::min or an if branch?

A very common pattern in programming is to cap a value at a maximum after some kind of update. What I'd like to know, is if there's a difference between the following two pieces of code, and if one should be preferred: value += increment; value =…
voltrevo
  • 9,870
  • 3
  • 28
  • 33
26
votes
4 answers

Ruby: How to find the index of the minimum array element?

Is there any way to rewrite this more elegant? I think, that it's a bad piece of code and should be refactored. >> a = [2, 4, 10, 1, 13] => [2, 4, 10, 1, 13] >> index_of_minimal_value_in_array = a.index(a.min) => 3
kyrylo
  • 1,691
  • 1
  • 15
  • 22
26
votes
3 answers

Select the minimum value for each row join by another table

I have the following table: Table1 Table2 CardNo ID Record Date ID Name Dept 1 101 8.00 11/7/2013 101 Danny Green 2 101 13.00 11/7/2013 102 …
wood
  • 275
  • 1
  • 3
  • 7
26
votes
5 answers

Set highcharts y-axis min value to 0, unless there is negative data

I'm having an issue with highcharts where I have a number of different charts being generated by JSON calls. For the majority of these charts I need the minimum y-axis value to be set at 0, however there are a couple of occasions where negative…
Pryor74
  • 261
  • 1
  • 3
  • 3
25
votes
5 answers

How can I find the minimum value in a map?

I have a map and I want to find the minimum value (right-hand side) in the map. Here is how I did it: bool compare(std::pair i, pair j) { return i.second <…
Sunny
  • 1,973
  • 2
  • 17
  • 22
21
votes
2 answers

What is the minimum value of a 32-bit signed integer?

What is the minimum value of a 32-bit signed integer, happens to be the security "challenge" question in order to make an account at [this website](edit: link is now malware) (don't judge I'm just curious and bored). I assumed they were talking…
java
  • 1,319
  • 6
  • 15
  • 30
20
votes
1 answer

Swift 4 - Setting a minimum deployment target

The current deployment target is 11.0 which is fine. However, I would like to know how I would set a minimum of 8.0?
Niall Kiddle
  • 1,477
  • 1
  • 16
  • 35
20
votes
2 answers

Pandas min() of selected row and columns

I am trying to create a column which contains only the minimum of the one row and a few columns, for example: A0 A1 A2 B0 B1 B2 C0 C1 0 0.84 0.47 0.55 0.46 0.76 0.42 0.24 0.75 1 0.43 …
yash.trojan.25
  • 211
  • 1
  • 3
  • 8
19
votes
14 answers

Prolog, find minimum in a list

in short: How to find min value in a list? (thanks for the advise kaarel) long story: I have created a weighted graph in amzi prolog and given 2 nodes, I am able to retrieve a list of paths. However, I need to find the minimum value in this path…
Roy
  • 763
  • 2
  • 8
  • 18
19
votes
13 answers

Java Minimum and Maximum values in Array

My code does not give errors, however it is not displaying the minimum and maximum values. The code is: Scanner input = new Scanner(System.in); int array[] = new int[10]; System.out.println("Enter the numbers now."); for (int i = 0; i <…
user2673161
  • 1,675
  • 4
  • 23
  • 28
17
votes
1 answer

Mysql minimum function

Is there a predefined MySQL function that returns minimum of its arguments' values (MINIMUM(1,16) -> 1)? To be more specific, I have a time-on-site column in one of my mysql tables. Every visitor polls my server every 30 sec making an update: UPDATE…
tsds
  • 8,700
  • 12
  • 62
  • 83
16
votes
2 answers

R return the index of the minimum column for each row

I have a data.frame that contains 4 columns (given below). I want to find the index of the minimum column (NOT THE VALUE) for each row. Any idea hiw to achieve that? > d V1 V2 V3 V4 1 0.388116155 0.98999967…
Vahid Mirjalili
  • 6,211
  • 15
  • 57
  • 80
1
2
3
70 71