Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 7
Default Code for sigma of product involving exponential - help

Hi all,

Could any guru help me with the following problem.



The formula I want to implement is :

f(n) = k1 x Sigma [w(i) x exp(-n-i)/tau1] where i goes from 1 to n-1.

n are my days that are arranged in a column C.

w(i) are rows in column C and the formula f (n) needs to go into rows of colmumn E.

Some more specifics of the problem with an image of my spreadsheet was described here : https://stackoverflow.com/questions/...27055#50027055


Appreciate any help implementing an elegant code, thanks.
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 3,872
Default Code for sigma of product involving exponential - help

Hi Ron,

Am Wed, 25 Apr 2018 09:58:09 -0700 (PDT) schrieb Ron George:

f(n) = k1 x Sigma [w(i) x exp(-n-i)/tau1] where i goes from 1 to n-1.


your formula:
=$B$4*SUMPRODUCT(D2*EXP(-1*(ROW(INDIRECT($A$2&":"&C2-1)))/$B$3))
^^^^^^

C2 = 1 and C2-1 = 0
That causes the error.
Try:
=$B$4*SUMPRODUCT(D2*EXP(-1*(ROW(INDIRECT($A$2&":"&C2)))/$B$3))


Regards
Claus B.
--
Windows10
Office 2016
  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 7
Default Code for sigma of product involving exponential - help

Hi Claus,

Thanks a lot. I put the "C2-1" bit there make it understand that the upper limit of sigma function is n-1 where n is the day on any row. If n = 3, C2-1 = 1.

Also, do you think my formula as a whole is correct?

If I manually attempt the calculation by setting k1 = 1 and tau1 = 1 and w(1) through w(4) as 20, 30, 40 & 50 respectively, f(n) comes out very different for the first 4 terms (manual calculation vs formula generated). Please see below :

Manual Calculation for f(n) :
7.35758882
13.74308889
19.77097751
25.66730821

Formula Generated f(n) :
7.35758823
15.09644173
22.12007171
28.56587158

Does the formula have to be pasted in E2 or beginning in E3?


Thanks!

Ron

On Wednesday, April 25, 2018 at 10:24:42 PM UTC+4, Claus Busch wrote:
Hi Ron,

Am Wed, 25 Apr 2018 09:58:09 -0700 (PDT) schrieb Ron George:

f(n) = k1 x Sigma [w(i) x exp(-n-i)/tau1] where i goes from 1 to n-1.


your formula:
=$B$4*SUMPRODUCT(D2*EXP(-1*(ROW(INDIRECT($A$2&":"&C2-1)))/$B$3))
^^^^^^

C2 = 1 and C2-1 = 0
That causes the error.
Try:
=$B$4*SUMPRODUCT(D2*EXP(-1*(ROW(INDIRECT($A$2&":"&C2)))/$B$3))


Regards
Claus B.
--
Windows10
Office 2016


  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 3,872
Default Code for sigma of product involving exponential - help

Hi Ron,

Am Wed, 25 Apr 2018 13:46:11 -0700 (PDT) schrieb Ron George:

Thanks a lot. I put the "C2-1" bit there make it understand that the upper limit of sigma function is n-1 where n is the day on any row. If n = 3, C2-1 = 1.

Also, do you think my formula as a whole is correct?


my understanding for your formula is a bit different.
Have a look:
https://1drv.ms/x/s!AqMiGBK2qniTgcxMl0ftNOJuVY6Duw


Regards
Claus B.
--
Windows10
Office 2016
  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 7
Default Code for sigma of product involving exponential - help

Hi Claus,

I see what you are doing.

Suppose we set first 4 rows of days as 1,2,3,4 and w(1), w(2), w(3) and w(4) as 10,20,30,40 respectively and compare the results with the manually generated output.

Your formula gives

f(1) = 10
f(2) = 20
f(3) = 41.03
f(4) = 60.12

Unless I forgot how to do math, :) here is the manually done computation :

When :

n = 1, no f(1) is calculated as upper limit tends to 0. No number exists?
n = 2, f(2) = 10 x e^(-1/4) = 7.7880
n = 3, f(3) = [10 x e^(-2/4)] + [20 x e^(-1/4)] = 21.6413
n = 4, f(4) = [10 x e^(-3/4)] + [20 x e^(-2/4)] + [30 x e^(-1/4)] = 40.2183


Do you see where I'm going...?


On Thursday, April 26, 2018 at 7:21:50 AM UTC+1, Claus Busch wrote:
Hi Ron,

Am Wed, 25 Apr 2018 13:46:11 -0700 (PDT) schrieb Ron George:

Thanks a lot. I put the "C2-1" bit there make it understand that the upper limit of sigma function is n-1 where n is the day on any row. If n = 3, C2-1 = 1.

Also, do you think my formula as a whole is correct?


my understanding for your formula is a bit different.
Have a look:
https://1drv.ms/x/s!AqMiGBK2qniTgcxMl0ftNOJuVY6Duw


Regards
Claus B.
--
Windows10
Office 2016




  #6   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 7
Default Code for sigma of product involving exponential - help

Claus,

Here is my understanding of the math, manually done.

Let#s say we set first 4 rows of n as 1,2,3,4.
Let's say we set first 4 rows of w as 10.20,30,40

When n = 1, computation does not exist (?)
When n = 2, f(2) = 10 x e^(-1) = 3.678
When n = 3, f(3) = 10 x e^(-2) + 20 x e^(-1) = 8.711
When n = 4, f(4) = 10 x e^(-3) + 20 x e^(-2) + 30 x e^(-1) = 14.240


The formula you provided starting with row 2 is :
$B$4*SUMPRODUCT(D2*(EXP(-1*(ROW(INDIRECT($A$2&":"&C2))-1)/$B$3)))


This gives me

f(1) = 10
f(2) = 27.35758882
f(2) = 45.09644173
f(4) = 62.12007171


See the difference? Thank you.


On Thursday, April 26, 2018 at 7:21:50 AM UTC+1, Claus Busch wrote:
Hi Ron,

Am Wed, 25 Apr 2018 13:46:11 -0700 (PDT) schrieb Ron George:

Thanks a lot. I put the "C2-1" bit there make it understand that the upper limit of sigma function is n-1 where n is the day on any row. If n = 3, C2-1 = 1.

Also, do you think my formula as a whole is correct?


my understanding for your formula is a bit different.
Have a look:
https://1drv.ms/x/s!AqMiGBK2qniTgcxMl0ftNOJuVY6Duw


Regards
Claus B.
--
Windows10
Office 2016


  #7   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 7
Default Code for sigma of product involving exponential - help



Claus,

Here is my understanding of the math, manually done.

Let#s say we set first 4 rows of n as 1,2,3,4.
Let's say we set first 4 rows of w as 10.20,30,40

When n = 1, computation does not exist (?)
When n = 2, f(2) = 10 x e^(-1) = 3.678
When n = 3, f(3) = 10 x e^(-2) + 20 x e^(-1) = 8.711
When n = 4, f(4) = 10 x e^(-3) + 20 x e^(-2) + 30 x e^(-1) = 14.240


The formula you provided starting with row 2 is :
$B$4*SUMPRODUCT(D2*EXP(-(ROW(INDIRECT("1:"&MAX(1,C2-1)))-1)/$B$3))


This gives me

f(1) = 10
f(2) = 27.35758882
f(2) = 45.09644173
f(4) = 62.12007171

See the difference? Thanks.


Ron


On Thursday, April 26, 2018 at 7:21:50 AM UTC+1, Claus Busch wrote:
Hi Ron,

Am Wed, 25 Apr 2018 13:46:11 -0700 (PDT) schrieb Ron George:

Thanks a lot. I put the "C2-1" bit there make it understand that the upper limit of sigma function is n-1 where n is the day on any row. If n = 3, C2-1 = 1.

Also, do you think my formula as a whole is correct?


my understanding for your formula is a bit different.
Have a look:
https://1drv.ms/x/s!AqMiGBK2qniTgcxMl0ftNOJuVY6Duw


Regards
Claus B.
--
Windows10
Office 2016


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Product Code Sanjo Setting up and Configuration of Excel 1 February 11th 10 05:02 AM
Product Code and Product Description setup Nastyashman Excel Worksheet Functions 4 July 6th 09 05:48 PM
Vlookup code product and to copy commentary with photo of the product in vba [email protected] Excel Programming 0 October 2nd 06 03:54 AM
ROBBYN - RE -Code Refinement involving blank cell(s) COULD NOT POST FOLLOWUP ross Excel Programming 1 June 2nd 04 01:21 AM
Code Refinement involving blank cell(s) Robbyn Excel Programming 1 June 1st 04 01:16 AM


All times are GMT +1. The time now is 11:51 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"