recurrence

Cron job run every x weeks and on specific days [closed]

。_饼干妹妹 提交于 2019-12-04 11:49:44
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 7 years ago . I want to create a cron job that runs every x weeks and on a specific weekdays. for example: run every 2 weeks on midnight every Sunday and Monday. the cron expression is stored for every "plan" and i use ncrontab function in SQL Server 2008 to generate the dates of given cron expression. Is there an expression

Is there a way to implement recurrence in numpy without for-loops?

主宰稳场 提交于 2019-12-03 22:36:22
问题 I have the following problem. There is a matrix X and I need to generate a matrix H such that values of i_th row in matrix H are determined by i_th row of the matrix X and (i-1)_th row of matrix H . H_{i} = F(X_{i}, H_{i-1}) To calculate the first row of matrix H we use a special out-of-the-matrix row (row zero, so to say). Is there a way to implement this recurrence efficiently, in a vectorized form, without using for loops? 回答1: There is no other way (in general) except for an explicit for

How to determine the height of a recursion tree from a recurrence relation?

删除回忆录丶 提交于 2019-12-03 17:33:16
问题 How does one go about determining the height of a recursion tree, built when dealing with recurrence run-times? How does it differ from determining the height of a regular tree? alt text http://homepages.ius.edu/rwisman/C455/html/notes/Chapter4/ch4-9.gif edit: sorry, i meant to add how to get the height of the recursion tree from the recurrence relation . 回答1: If recurrence is in the form of T(n) = aT(n/b) + f(n) then the depth of the tree is log base b of n. For example, 2T(n/2) + n

Calculating the Recurrence Relation T(n)=T(n-1)+logn

天大地大妈咪最大 提交于 2019-12-03 16:35:25
We are to solve the recurrence relation through repeating substitution: T(n)=T(n-1)+logn I started the substitution and got the following. T(n)=T(n-2)+log(n)+log(n-1) By logarithm product rule, log(mn)=logm+logn, T(n)=T(n-2)+log[n*(n-1)] Continuing this, I get T(n)=T(n-k)+log[n*(n-1)*...*(n-k)] We know that the base case is T(1), so n-1=k -> k=n+1, and substituting this in we get T(n)=T(1)+log[n*(n-1)*...*1] Clearly n*(n-1)*...*1 = n! so, T(n)=T(1)+log(n!) I do not know how to solve beyond this point. Is the answer simply O(log(n!)) ? I have read other explanations saying that it is Θ(nlogn)

Recursion of for's

此生再无相见时 提交于 2019-12-03 15:31:05
I'm tried to figure out how to do it for quite of time and its not working as intended; I'm writing a code where there is 1 to k numbers, I need to find all possible combination without repeats. e.g. for 3: 1, 2, 3, 12, 13. Example for counting 4-digits numbers with 1, 2, 3, 4, 5. int k = 5; for (int p = 0; p < k; p++) { for (int i = p+1; i < k; i++) { for (int j = i + 1; j < k; j++) { for (int h = j + 1; h < k; h++) { cout << p + 1 << i + 1 << j + 1 << h + 1 << endl; } } } } And there is example for 3-digits number with 1, 2, 3. int k = 4 for (int p = 0; p < k; p++) { for (int i = p+1; i < k;

How would you store possibly recurring times?

自闭症网瘾萝莉.ら 提交于 2019-12-03 13:33:56
问题 I need to store whether something happens once, daily, weekdays, weekly, some days of the week, some days of the month, which may be numerical or symbolic, like first Monday of each month, and so on. Any recommendations? Any code, data structure or schema to look at? 回答1: There are complex solutions and easy solutions. The two easiest solutions are: Fan out recurring events up to some constant number of instances, or up to some fixed date range in the future. Store a FK recurrence_id with

Non-Linear Recurrence Relation

十年热恋 提交于 2019-12-03 10:20:27
问题 How can I find Nth term for this recurrence relation F(n) = F(n-1) + F(n-2) + F(n-1)*F(n-2) I have to find Nth term for this recurrence relation modulo 10^9+7 . I know how to find Nth term for linear recurrence relations but unable to proceed for this. 1<=N<=10^9 F(0) and F(1) are provided as an input. 回答1: There's a trick. Let G(n) = F(n) + 1 . The equation F(n) = F(n-1) + F(n-2) + F(n-1)*F(n-2) becomes G(n) - 1 = G(n-1) - 1 + G(n-2) - 1 + (G(n-1) - 1) * (G(n-2) - 1) = G(n-1) - 1 + G(n-2) -

Cron job run every x weeks and on specific days [closed]

点点圈 提交于 2019-12-03 08:10:57
Closed. This question is off-topic. It is not currently accepting answers. Learn more . Want to improve this question? Update the question so it's on-topic for Stack Overflow. I want to create a cron job that runs every x weeks and on a specific weekdays. for example: run every 2 weeks on midnight every Sunday and Monday. the cron expression is stored for every "plan" and i use ncrontab function in SQL Server 2008 to generate the dates of given cron expression. Is there an expression for it? or even join of several expressions? I've tried to use the following expression, but it always gives

Django - How to run a function EVERYDAY?

蹲街弑〆低调 提交于 2019-12-03 07:20:19
I want to run this function everyday midnight to check expiry_date_notification. what can I do? I'm new to django and python. def check_expiry_date(request): products = Product.objects.all() for product in products: product_id = product.id expiry_date = product.expiry_date notification_days = product.notification_days check_date = int((expiry_date - datetime.datetime.today()).days) if notification_days <= check_date: notification = Notification(product_id=product_id) notification.save() As others have said, Celery can schedule tasks to execute at a specific time . from celery.schedules import

Solving the recurrence relation T(n) = √n T(√n) + n [closed]

半城伤御伤魂 提交于 2019-12-03 04:36:39
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 8 years ago . Is it possible to solve the recurrence relation T(n) = √n T(√n) + n Using the Master Theorem? It is not of the form T(n) = a ⋅ T(n / b) + f(n) but this problem is given in the exercise of CLRS chapter 4. 回答1: This cannot be solved by the Master Theorem. However, it can be solved using the recursion tree method