min

T-sql get min and max value for each day

冷暖自知 提交于 2019-12-01 00:57:56
I am trying to write a query where for each day I get the minimum and maximum price for each item from price details table. In price details table prices are set multiple times a day so there are many records for the same date. So I want a table where there is one row for each date and then join that table to the same table so for each distinct date I want the minimum and maximum value. USE [a_trading_system] GO /****** Object: Table [dbo].[price_details] Script Date: 07/01/2012 17:28:31 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO SET ANSI_PADDING ON GO CREATE TABLE [dbo].[price

Is there a numpy max min function?

╄→尐↘猪︶ㄣ 提交于 2019-11-30 22:45:24
问题 Is there a numpy function that gives for a given numpy array its maximum - minimum value, i.e. numpy.max(a) - numpy.min(a) ? e.g. numpy.xxx([4,3,2, 6] = 4 since max = 6, min = 2, 6 - 4 = 2) Reason: performance increase since max and min would cause twice the iteration of the array (which is in my case 7.5 million or more numbers). 回答1: Indeed there is such a function -- it's called numpy.ptp() for "peak to peak". 来源: https://stackoverflow.com/questions/9312756/is-there-a-numpy-max-min

T-sql get min and max value for each day

情到浓时终转凉″ 提交于 2019-11-30 19:38:34
问题 I am trying to write a query where for each day I get the minimum and maximum price for each item from price details table. In price details table prices are set multiple times a day so there are many records for the same date. So I want a table where there is one row for each date and then join that table to the same table so for each distinct date I want the minimum and maximum value. USE [a_trading_system] GO /****** Object: Table [dbo].[price_details] Script Date: 07/01/2012 17:28:31 ****

MinGW error: 'min' is not a member of 'std'

若如初见. 提交于 2019-11-30 19:07:44
I'm trying to convert some VC++ 6 code to a console app using only the standard libraries but am getting the following error from MinGW (whatever version is supplied with the Code::Blocks 10.05 IDE): error: 'min' is not a member of 'std' This is related to the following line of code: L.Precision=std::min(1.e-4,0.001*res); L.Precision is a double , and res is a double . Previously this line was: L.Precision=min(1.e-4,0.001*res); But this gives the error: error: 'min' was not declared in this scope Here are the headers in the file in question: #include<stdio.h> #include<math.h> //#include

What's “<?=” operator in C++? [duplicate]

Deadly 提交于 2019-11-30 17:05:33
This question already has an answer here: C extension: <? and >? operators 2 answers I came across the following code here , which is from the C++ implementation of Dijkstra algorithm using an adjacency matrix. //read in edges keeping only the minimum for(int i=0; i<E; i++) { int v1,v2,tmp; fin >> v1; fin >> v2; fin >> tmp; adjmat[v1][v2]<?=tmp; // <?= sets left to min(left,right) adjmat[v2][v1]<?=tmp; } Pay attention to the last two lines, which apply operator <?= . As being commented, the following line adjmat[v1][v2]<?=tmp; // <?= sets left to min(left,right) will set left to min(left,right

Algorithm splitting array into sub arrays where the maximum sum among all sub arrays is as low as possible

为君一笑 提交于 2019-11-30 15:43:28
Let's say we have an array of ints: a = {2,4,3,5} And we have k = 3. We can split array a in k (3) sub arrays in which the order of the array cannot be changed. The sum of each sub array has to be as low as possible so that the maximum sum among all sub arrays is as low as possible. For the above solution this would give {2, 4}, {3}, {5} which has a maximum sum of 6 (4 + 2). A wrong answer would be {2}, {4, 3}, {5}, because the maximum sum is 7 (4 + 3) in this case. I've tried creating a greedy algorithm which calculates the average of the entire array by summing all ints and dividing it by

Making javax validation error message more specific

柔情痞子 提交于 2019-11-30 12:06:38
Sorry if this question has been covered somewhere before. If it has please link me to it, I haven't been able to find a satisfactory answer as yet. I've been looking around trying to find a way to have the error messages provided by my javax validation more specific. The message I currently have for my @Min annotation is specified in the ValidationMessages.properties file: javax.validation.constraints.Min.message=The value of this variable must be less than {value}. and this prints out as would be expected The value of this variable must be less than 1 What I would like to have is the message

Fastest way to zero out low values in array?

柔情痞子 提交于 2019-11-30 11:18:31
问题 So, lets say I have 100,000 float arrays with 100 elements each. I need the highest X number of values, BUT only if they are greater than Y. Any element not matching this should be set to 0. What would be the fastest way to do this in Python? Order must be maintained. Most of the elements are already set to 0. sample variables: array = [.06, .25, 0, .15, .5, 0, 0, 0.04, 0, 0] highCountX = 3 lowValY = .1 expected result: array = [0, .25, 0, .15, .5, 0, 0, 0, 0, 0] 回答1: This is a typical job

Is there a way to make numpy.argmin() as fast as min()?

匆匆过客 提交于 2019-11-30 11:07:57
I'm trying to find the minimum array indices along one dimension of a very large 2D numpy array. I'm finding that this is very slow (already tried speeding it up with bottleneck, which was only a minimal improvement). However, taking the straight minimum appears to be an order of magnitude faster: import numpy as np import time randvals = np.random.rand(3000,160000) start = time.time() minval = randvals.min(axis=0) print "Took {0:.2f} seconds to compute min".format(time.time()-start) start = time.time() minindex = np.argmin(randvals,axis=0) print "Took {0:.2f} seconds to compute argmin".format

Tuple pairs, finding minimum using python

戏子无情 提交于 2019-11-30 10:27:00
问题 I want to find the minimum of a list of tuples sorting by a given column. I have some data arranged as a list of 2-tuples for example. data = [ (1, 7.57), (2, 2.1), (3, 1.2), (4, 2.1), (5, 0.01), (6, 0.5), (7, 0.2), (8, 0.6)] How may I find the min of the dataset by the comparison of the second number in the tuples only? i.e. data[0][1] = 7.57 data[1][1] = 2.1 min( data ) = (5, 0.01) min( data ) returns (1, 7.57) , which I accept is correct for the minimum of index 0, but I want minimum of