Questions tagged [intervals]

Intervals are used to measure “distance” between values.

intervals
Filter by
Sorted by
Tagged with
77 votes
9 answers
18k views

How to join two dataframes for which column values are within a certain range?

Given two dataframes df_1 and df_2, how to join them such that datetime column df_1 is in between start and end in dataframe df_2: print df_1 timestamp A B 0 2016-05-14 10:...
DougKruger's user avatar
  • 4,564
57 votes
7 answers
123k views

How can I use ranges in a switch case statement using JavaScript?

How can I use ranges in a switch case statement using JavaScript? So, instead of writing code for each and every single possibility, I'd like to group them in ranges, For example: switch(myInterval){ ...
Lave Loos's user avatar
  • 1,262
132 votes
9 answers
115k views

Do something every x minutes in Swift

How can I run a function every minute? In JavaScript I can do something like setInterval, does something similar exist in Swift? Wanted output: Hello World once a minute...
JOSEFtw's user avatar
  • 10k
58 votes
11 answers
79k views

Show TimePicker with minutes intervals in android

My application show a TimePickerDialog to set a time. I want that the timePickerDialog show the minutes with an interval of 5 minutes. This works fine with this code: private final int ...
Sergio76's user avatar
  • 3,926
9 votes
1 answer
52k views

Create a simple countdown in processing

I have searched up so many sites on Google to try and get this to work but NO ONE seems to have this anywhere , and if they do it's just NOT working with my program... What I am trying to achieve is ...
D34thSt4lker's user avatar
45 votes
4 answers
287k views

How can I plot data with confidence intervals?

If I have 10 values, each of which has a fitted value F, and an upper and lower confidence interval U and L: set.seed(0815) F <- runif(10, 1, 2) L <- runif(10, 0, 1) U <- runif(10, 2, 3) ...
Kazo's user avatar
  • 1,235
8 votes
7 answers
35k views

format interval with to_char

Following SQL command select TO_CHAR(NVL(arg1 - arg2, TO_DSINTERVAL('0 00:00:00'))) from table1 produces a result of the format: +000000000 00:03:01.954000. Is it possible to enter a special format ...
Georg Leber's user avatar
  • 3,490
246 votes
9 answers
295k views

How do I convert an interval into a number of hours with postgres?

Say I have an interval like 4 days 10:00:00 in postgres. How do I convert that to a number of hours (106 in this case?) Is there a function or should I bite the bullet and do something like extract(...
agnul's user avatar
  • 12.8k
12 votes
7 answers
3k views

Find which interval row in a data frame that each element of a vector belongs in

I have a vector of numeric elements, and a dataframe with two columns that define the start and end points of intervals. Each row in the dataframe is one interval. I want to find out which interval ...
Ben's user avatar
  • 42k
49 votes
15 answers
52k views

How to wrap a float to the interval [-pi, pi)

I'm looking for some nice C code that will accomplish effectively: while (deltaPhase >= M_PI) deltaPhase -= M_TWOPI; while (deltaPhase < -M_PI) deltaPhase += M_TWOPI; What are my options?
P i's user avatar
  • 29.9k
24 votes
6 answers
59k views

In JavaScript, how can I have a function run at a specific time?

I have a website that hosts a dashboard: I can edit the JavaScript on the page and I currently have it refreshing every five seconds. I am trying to now get a window.print() to run every day at 8 AM....
user3738622's user avatar
19 votes
6 answers
15k views

Union of intervals

I've got a class representing an interval. This class has two properties "start" and "end" of a comparable type. Now I'm searching for an efficient algorithm to take the union of a set of such ...
drvj's user avatar
  • 355
83 votes
5 answers
60k views

Using a variable period in an interval in Postgres

I have a relation that maintains monthly historical data. This data is added to the table on the last day of each month. A service I am writing can then be called specifying a month and a number of ...
Belizzle's user avatar
  • 1,335
25 votes
6 answers
13k views

Python: Mapping from intervals to values

I'm refactoring a function that, given a series of endpoints that implicitly define intervals, checks if a number is included in the interval, and then return a corresponding (not related in any ...
Agos's user avatar
  • 18.9k
21 votes
4 answers
11k views

Python - Rounding by quarter-intervals

I'm running into the following issue: Given various numbers like: 10.38 11.12 5.24 9.76 does an already 'built-in' function exists to round them up to the closest 0.25 step like e.g.: 10.38 --> ...
Daniyal's user avatar
  • 885
5 votes
2 answers
4k views

Find date range overlaps within the same table, for specific user MySQL

I am by no means an MySQL expert, so I am looking for any help on this matter. I need to perform a simple test (in principle), I have this (simplified) table: tableid | userid | car | From ...
PawelKosi's user avatar
  • 151
50 votes
3 answers
214k views

Working with INTERVAL and CURDATE in MySQL

I'm building a chart and I want to receive data for each month. Here's my first request which is working: SELECT s.GSP_nom AS nom, timestamp, AVG( v.vote + v.prix ) /2 AS avg FROM votes_serveur ...
sf_tristanb's user avatar
  • 8,785
31 votes
4 answers
22k views

Plotting labeled intervals in matplotlib/gnuplot

I have a data sample which looks like this: a 10:15:22 10:15:30 OK b 10:15:23 10:15:28 OK c 10:16:00 10:17:10 FAILED b 10:16:30 10:16:50 OK What I want is to plot the above data in the following way:...
dm3's user avatar
  • 2,058
29 votes
5 answers
12k views

Algorithm to find the maximum sum in a sequence of overlapping intervals

The problem I am trying to solve has a list of intervals on the number line, each with a pre-defined score. I need to return the maximum possible total score. The catch is that the intervals overlap,...
efficiencyIsBliss's user avatar
29 votes
3 answers
33k views

PostgreSQL how to concat interval value '2 days'

In PostgreSQL I want to concat the current_timestamp with an interval as follows: select current_timestamp + interval 2||' days' But when I do, I get an error: [Err] ERROR: syntax error at or near ...
d-man's user avatar
  • 57.8k
221 votes
5 answers
487k views

Postgresql query between date ranges

I am trying to query my postgresql db to return results where a date is in certain month and year. In other words I would like all the values for a month-year. The only way i've been able to do it ...
John's user avatar
  • 6,737
56 votes
3 answers
215k views

How do you create vectors with specific intervals in R?

I have a question about creating vectors. If I do a <- 1:10, "a" has the values 1,2,3,4,5,6,7,8,9,10. My question is how do you create a vector with specific intervals between its elements. For ...
Luli's user avatar
  • 613
38 votes
4 answers
34k views

ISO 8601 Time Interval Parsing in Java

ISO 8601 defines a syntax for representing a time interval. There are four ways to express a time interval: Start and end, such as "2007-03-01T13:00:00Z/2008-05-11T15:30:00Z" Start and duration, ...
fellahst's user avatar
  • 651
21 votes
4 answers
9k views

Finding matching interval(s) in pandas Intervalindex

There's this interesting API called Intervalindex new in 0.20 that lets you create an index of intervals. Given some sample data: data = [(893.1516130000001, 903.9187099999999), (882.384516, 893....
this be Shiva's user avatar
20 votes
4 answers
86k views

Run a function in time interval in jQuery

I want to make a banner by using jQuery. When the page loaded script will show a group of photos one by one. For example, the controller sends 10 photos and each photo will be shown in 30 seconds ...
Sesen's user avatar
  • 362
17 votes
5 answers
40k views

How to add markers on Google Maps polylines based on distance along the line?

I am trying to create a Google Map where the user can plot the route he walked/ran/bicycled and see how long he ran. The GPolyline class with it’s getLength() method is very helpful in this regard (at ...
mikl's user avatar
  • 24k
11 votes
3 answers
15k views

SQL: Merge Date Ranges

I've a table, which describes work slices of a business working calendar: (date format is 24 hours format) PK | STARTDATE | ENDDATE __________________________________________ 1 | 2012/07/...
user1552089's user avatar
10 votes
4 answers
5k views

R - Faster Way to Calculate Rolling Statistics Over a Variable Interval

I'm curious if anyone out there can come up with a (faster) way to calculate rolling statistics (rolling mean, median, percentiles, etc.) over a variable interval of time (windowing). That is, ...
EconomiCurtis's user avatar
8 votes
3 answers
7k views

javascript interval

How can I use interval in js? For example I want to call a function every 5 seconds? <script type="text/javascript"> setInterval(openAPage(), 5000); function openAPage() { var startTime = ...
ramazan murat's user avatar
4 votes
6 answers
6k views

how to overlap intervals efficiently

I require your help, I have a problem (see picture), I have let say two arrays and each of this array contains intervals with different length and real values and I need to find out how I'm gone ...
Kaisel von Kassel's user avatar
11 votes
1 answer
3k views

Why does php datetime diff depend on time zones?

See the following code: function printDiff($tz) { $d1 = new DateTime("2015-06-01", new DateTimeZone($tz)); $d2 = new DateTime("2015-07-01", new DateTimeZone($tz)); $diff = $d1->diff($...
Csongor Halmai's user avatar
10 votes
3 answers
8k views

SQL to find time elapsed from multiple overlapping intervals

Not using MSSQL or DB2 or Oracle. No CTE. No OVERLAP predicate. No INTERVAL data type. The situation: on a vehicle to be repaired work can not start until all parts ordered for the job have been ...
jon's user avatar
  • 111
8 votes
5 answers
33k views

AJAX Interval Refresh?

I'm trying to make an AJAX function update about 30 seconds. I have a simple version of that done, here is the code. var refInterval = window.setInterval('update()', 30000); // 30 seconds var update ...
bin0's user avatar
  • 125
7 votes
4 answers
6k views

Merging intervals in one pass in SQL

Let's say I have a table with two columns: start and end, both integers, and the table is ordered by the first, then second column. Each row represents an interval. What I need is the table of ...
reinierpost's user avatar
  • 8,533
5 votes
1 answer
5k views

Repeat Alarm Manager At Exact Interval in API=>19?

I had a massive reading and still I think there is not a clear/complete Answer to this question. First some stuff to clarify : this question is not concern with battery saving on phone but more about ...
bastami82's user avatar
  • 6,083
4 votes
3 answers
3k views

ContentResolver.addPeriodicSync interval round up

My sync adapter does work perfectly well except for one little thing which bugs the sh*t out of me for the last few hours... For my app i want the sync adapter to run with an interval of 10 seconds. ...
harco gijsbers's user avatar
31 votes
6 answers
57k views

Timing in JS - multiple setIntervals running at once and starting at the same time?

Let's say I have a function: myFunc = function(number) { console.log("Booyah! "+number); } And I want it to run on a set interval. Sounds like I should use setInterval, huh! But what if I want to ...
Joshua Soileau's user avatar
15 votes
4 answers
19k views

Create a jQuery special event for content changed

I'm trying to create a jQuery special event that triggers when the content that is bound, changes. My method is checking the content with a setInterval and check if the content has changed from last ...
Sindre Sorhus's user avatar
13 votes
5 answers
14k views

Data structure for handling intervals

I have got a series of time intervals (t_start,t_end), that cannot overlap, i.e.: t_end(i) > t_start(i+1). I want to do the following operations: 1) Add new (Union of) intervals [ {(1,4),(8,10)} U (3,...
Luís Guilherme's user avatar
9 votes
2 answers
4k views

Range join data.frames - specific date column with date ranges/intervals in R

Although the details of this are, of course, app specific, in the SO spirit I'm trying to keep this as general as possible! The basic problem is how to merge data.frames by date when one data.frame ...
user2728808's user avatar
5 votes
11 answers
9k views

Postgres birthdays selection

I work with a Postgres database. This DB has a table with users, who have a birthdate (date field). Now I want to get all users who have their birthday in the upcoming week.... My first attempt: ...
Mike's user avatar
  • 51
5 votes
4 answers
4k views

Does an open-ended interval implementation exist for Java?

I've got a classification of certain values in different intervals. Most have the form [20-30], but some are of the form [30-infinite). Is there an interval class you know of which can represent: an ...
boutta's user avatar
  • 24.5k
4 votes
3 answers
2k views

Merge Records Over Time Interval

Let me begin by saying this question pertains to R (stat programming language) but I'm open straightforward suggestions for other environments. The goal is to merge outcomes from dataframe (df) A ...
bnjmn's user avatar
  • 4,548
3 votes
4 answers
3k views

Python interval interesction

My problem is as follows: having file with list of intervals: 1 5 2 8 9 12 20 30 And a range of 0 200 I would like to do such an intersection that will report the positions [start end] between my ...
Irek's user avatar
  • 439
2 votes
3 answers
6k views

Counting values by day/hour with timeseries in MATLAB

So, I'm beginning to use timeseries in MATLAB and I'm kinda stuck. I have a list of timestamps of events which I imported into MATLAB. It's now a 3000x25 array which looks like 2000-01-01T00:01:01+...
ehertele's user avatar
  • 221
47 votes
4 answers
31k views

Run a function periodically in Scala

I want to call an arbitrary function every n seconds. Basically I want something identical to SetInterval from Javascript. How can I achieve this in Scala?
src091's user avatar
  • 2,817
28 votes
4 answers
70k views

MySQL select rows from exactly 7 days ago

I'm completely stumped on this one, being trying for hours but with no success, hoping someone can help. Trying to build a cron script to run daily that returns the rows that are exactly 7 days older ...
Tim Blackburn's user avatar
20 votes
4 answers
17k views

SymPy: Limit symbol/variable to interval

Using SymPy, is it possible to limit the possible values of a symbol/variable to a certain range? I now I can set some properties while defining symbols, like positive=True, but I need more control, i....
Se Norm's user avatar
  • 1,755
17 votes
1 answer
51k views

Making a interval timer in Java android

I have plans to create an interval app using timers. It should just be the most basic So I'll have to add some more when I've understood the basics. What I want to achieve is to select the number of ...
Hans Fredrik's user avatar
16 votes
6 answers
23k views

How to map the PostgreSQL Interval column type in Hibernate?

Under PostgreSQL, I'm using PersistentDuration for the mapping between the sql type interval & duration but it doesn't work. Another user found the same issue & come with his own class: ...
adam's user avatar
  • 161

1
2 3 4 5 6