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
920 questions
360
votes
16 answers

Get the key corresponding to the minimum value within a dictionary

If I have a Python dictionary, how do I get the key to the entry which contains the minimum value? I was thinking about something to do with the min() function... Given the input: {320:1, 321:0, 322:3} It would return 321.
tjvr
  • 15,039
  • 6
  • 21
  • 26
246
votes
8 answers

How to scale down a range of numbers with a known min and max value

So I am trying to figure out how to take a range of numbers and scale the values down to fit a range. The reason for wanting to do this is that I am trying to draw ellipses in a java swing jpanel. I want the height and width of each ellipse to be…
user650271
  • 2,615
  • 3
  • 15
  • 8
59
votes
7 answers

How can I find the minimum cut on a graph using a maximum flow algorithm?

I need to find the minimum cut on a graph. I've been reading about flow networks, but all I can find are maximum flow algorithms such as Ford-Fulkerson, push-relabel, etc. Given the max flow-min cut theorem, is it possible to use one of those…
cesarbs
  • 819
  • 1
  • 6
  • 9
54
votes
2 answers

Numpy minimum in (row, column) format

How can I know the (row, column) index of the minimum of a numpy array/matrix? For example, if A = array([[1, 2], [3, 0]]), I want to get (1, 1) Thanks!
yassin
  • 5,881
  • 7
  • 31
  • 38
52
votes
4 answers

Python: Find index of minimum item in list of floats

How can I find the index of the minimum item in a Python list of floats? If they were integers, I would simply do: minIndex = myList.index(min(myList)) However, with a list of floats I get the following error, I assume because float equality…
thornate
  • 4,202
  • 9
  • 36
  • 42
39
votes
4 answers

Is there a vectorized parallel max() and min()?

I have a data.frame with columns "a" and "b". I want to add columns called "high" and "low" that contain the highest and the lowest among columns a and b. Is there a way of doing this without looping over the lines in the dataframe? edit: this is…
Generic Person
  • 695
  • 1
  • 6
  • 9
34
votes
4 answers

find a minimum value in an array of floats

how would one go about finding the minimum value in an array of 100 floats in python? I have tried minindex=darr.argmin() and print darr[minindex] with import numpy (darr is the name of the array) but i get: minindex=darr.argmin() AttributeError:…
pjehyun
  • 891
  • 2
  • 9
  • 11
32
votes
4 answers

DataAnnotations StringLength Attribute MVC - without max value

I am using Data Annotations for Model validation in MVC4 and am currently using the StringLengthAttribute however i do NOT want to specify a maximum value (currently set at 50) but DO want to specify a minimum string length value. Is there a way to…
31
votes
4 answers

Why isn't the CSS property 'line-height' letting me make tight line-spaces in Chrome?

I have a paragraph tag that I defined elsewhere with a line height of 15px, and I have another paragraph tag further down the page where I want to make the line height around 10px. Funny thing is, it won't let me get down to 10px or anything smaller…
Simon Suh
  • 8,581
  • 21
  • 75
  • 99
31
votes
4 answers

Find the maximum and minimum value of every column and then find the maximum and minimum value of every row

I've got this matrix: a <- matrix(rnorm(1000 * 18, mean = 100, sd = sqrt(10)), 1000, 18) I would like to find the maximum and minimum value of every column and the maximum and minimum value of every row.
Kostas Dimakis
  • 1,033
  • 1
  • 10
  • 20
30
votes
5 answers

I have need the N minimum (index) values in a numpy array

Hi I have an array with X amount of values in it I would like to locate the indexs of the ten smallest values. In this link they calculated the maximum effectively, How to get indices of N maximum values in a numpy array? however I cant comment on…
astrochris
  • 1,546
  • 5
  • 18
  • 35
29
votes
5 answers

Maximum value for Float in Java?

The following question indicates that the minimum value of a Double is -Double.MAX_VALUE. Is this also true for Float (i.e., -Float.MAX_VALUE)?
Jérôme Verstrynge
  • 51,859
  • 84
  • 263
  • 429
28
votes
14 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
  • 14,036
  • 13
  • 48
  • 65
28
votes
3 answers

List minimum in Python with None?

Is there any clever in-built function or something that will return 1 for the min() example below? (I bet there is a solid reason for it not to return anything, but in my particular case I need it to disregard None values really bad!) >>> max([None,…
c00kiemonster
  • 19,305
  • 31
  • 84
  • 128
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
1
2 3
61 62