min

Showing Distinct Values with Aggregates

走远了吗. 提交于 2019-12-25 18:32:13
问题 I have a table for recording daily price from different suppliers. My goal is to find the best (low price) supplier. The table structure is Table Name: lab1 Columns: ID, Product_ID, Price_date, Price, Supplier ----------------------------------------------------------------------------------- ID Product_ID Price_date Price Supplier -------------------------------------------------------------------------------------- 1 8 26-10-2014 1300 SP1 2 8 05-10-2014 1600 SP2 3 8 15-10-2014 1300 SP1 4 8

Finding the min max and average of an array

南笙酒味 提交于 2019-12-25 16:09:09
问题 I need to find the min, max, and average of the balances. I have done this before using for loops, but never with a while loop. Is there a way to pull the min max and average straight from the array without interfering with the while loop perhaps? 10 Helene 1000 Jordan 755 Eve 2500 Ken 80 Andrew 999 David 1743 Amy 12 Sean 98 Patrick 7 Joy 14 where 10 is the number of accounts import java.util.*; import java.io.*; import java.util.Arrays; public class bankaccountmain { public static void main

Normalizing Data Using Javascript

余生颓废 提交于 2019-12-25 08:15:24
问题 I have multiple arrays of size 262144, and I am trying to use the following code to set all the values of each array to between 0 and 1, inclusive. To be clear, each array will be normalized differently because each has different values. var i; var max = Number.MIN_VALUE; var min = Number.MAX_VALUE; for (i = 0; i < array.length; i++) { if(array[i]>max) { max = array[i]; } } for (i = 0; i < array.length; i++){ if(array[i]<min) { min = array[i]; } } for (i = 0; i < array.length; i++) { var norm

Python - File does not exist error

北城余情 提交于 2019-12-25 04:07:30
问题 I'm trying to do a couple things here with the script below (it is incomplete). The first thing is to loop through some subdirectories. I was able to do that successfully. The second thing was to open a specific file (it is the same name in each subdirectory) and find the minimum and maximum value in each column EXCEPT the first. Right now I'm stuck on finding the max value in a single column because the files I'm reading have two rows which I want to ignore. Unfortunately, I'm getting the

awk/bash remove lines with an unique id and keep the lines that has the max/min value in a column under the same ID

六眼飞鱼酱① 提交于 2019-12-25 02:52:09
问题 If we have the following input and would like to firstly, detect if the cpd_number ($2) is unique in the file, remove the whole row. In this case, the line with "cpd-6666666" should be removed. Secondly, if there are multiple lines kept under the same "cpd_number", only prints out the two lines which has the max and min "log_ratio" ($17). targetID,cpd_number,Cell_assay_id,Cell_alt_assay_id,Cell_type_desc,Cell_Operator,Cell_result_value,Cell_unit_value,assay_id,alt_assay_id,type_desc,operator

(Java) How to Keep Track of Numbers Entered by User for Determining Min and Max

巧了我就是萌 提交于 2019-12-25 01:43:33
问题 I have a homework assignment that is asking me to use an input dialog to ask the end user to enter a number, parse that String to an int, and then use a confirm dialog to ask if the user wants to enter another number. If they click yes, the program loops, and once they hit no, it takes all of the entered numbers and determines the min and max. How do I keep track of all the entered numbers without declaring multiple variables to hold them (since the user can technically enter an infinite

Octave/Matlab: min of two vectors

随声附和 提交于 2019-12-25 00:33:54
问题 Let's take two vectors: a = [1 ; 2; 3] b = [0 ; 9 ; -5] If I want minimum value of the vector and it's position I can simply: [x, ix] = min(a) I can also compare two vectors and get minimum values: > min(a, b) ans = 0 2 -5 But it is impossible to get positions of min values of two vectors: > [x, ix] = min(a, b) x = 0 2 -5 error: element number 2 undefined in return list Why? How to get them? Is there a simple method? 回答1: here's how to do that: [v id]=min([a,b]') 回答2: It's a matter of having

How to get nearest date?

﹥>﹥吖頭↗ 提交于 2019-12-24 16:58:58
问题 I have list of dates in a List . The user entered date will be compared with the list of dates. If the list contains that particular date, then the target date will be that date. If the list does not contain that particular date, then the nearest date should be taken as target date. For that I tried of using Min in LINQ: var nearestDiff = getAlldates.Min(date => Math.Abs((date - targetDate).Ticks)); var nearest = getAlldates.Where(date => Math.Abs((date - targetDate).Ticks) == nearestDiff)

Avoid lexicographic ordering of numerical values with Python min() max()

夙愿已清 提交于 2019-12-24 11:37:55
问题 I have a script to pull random numbers from a set of values. However, it broke today because min() and max() sort values by lexicographic order (so 200 is considered greater than 10000). How can I avoid lexicographic order here? Len key is on the right track but not quite right. I couldn't find any other key(s) that would help. data_set = 1600.csv, 2405.csv, 6800.csv, 10000.csv, 21005.csv First try: highest_value = os.path.splitext(max(data_set))[0] lowest_value = os.path.splitext(min(data

Dynamic minimum value for specfic range (mysql)

对着背影说爱祢 提交于 2019-12-24 11:29:58
问题 I am looking for a solution to SELECT (or otherwise derive) the values for Column C (minimum price for last 3 days only, not for the whole column). ---------------------------------------- Date | Unit_ | Low_3_days | | price | | ---------------------------------------- 2015-01-01 | 15 | should be: 15 | 2015-01-02 | 17 | should be: 15 | 2015-01-03 | 21 | should be: 15 | 2015-01-04 | 18 | should be: 17 | 2015-01-05 | 12 | should be: 12 | 2015-01-06 | 14 | should be: 12 | 2015-01-07 | 16 |