From: Manuel Schneckenreither <manuel.schnecki@gmail.com>
To: Michael Brand <michael.ch.brand@gmail.com>
Cc: Org Mode <emacs-orgmode@gnu.org>
Subject: Re: Table formula references
Date: Sun, 02 Apr 2017 17:31:13 +0000 [thread overview]
Message-ID: <CABA4qkcCDAGCc1uXmZykdRAUajNyzZ31O--Bra7Y0fUcGLtksA@mail.gmail.com> (raw)
In-Reply-To: <CALn3zojnOGCe=3U65D8hb4MyA=YKZj+Y=ye_C2EyMmS_YtVJBg@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 1289 bytes --]
Thanks, I'll take a look.
On Sun, Apr 2, 2017, 19:11 Michael Brand <michael.ch.brand@gmail.com> wrote:
> Hi Manuel
>
> Not sure if I understand your formulas right, so check my solutions with
> the formula debugger.
>
> On Thu, Mar 30, 2017 at 10:38 AM, Manuel Schneckenreither
> <manuel.schnecki@gmail.com> wrote:
>
> > So @5$3 should be 0.9^0*127 + 0.9^1*118 + 0.9^2*121 + 0.9^3*115.
>
> Emacs Calc has map with anonymous function and one or more vectors for
> the above:
>
> vsum(map(<0.9^#1 * #2>, [3, 2, 1, 0], [115, 121, 118, 127]))
>
> which equals
>
> vsum(map(<0.9^(4 - #1) * #2>, [1, 2, 3, 4], [115, 121, 118, 127]))
>
> The rest is Org spreadsheet. See the spreadsheet section in the Org
> user manual to understand this solution:
>
> | t | y_t | y_{t+1} |
> |---+-----+---------|
> | 1 | 115 | 115.000 |
> | 2 | 121 | 224.500 |
> | 3 | 118 | 320.050 |
> | 4 | 127 | 415.045 |
> #+TBLFM: $3 = vsum(map(<0.9^($1 - #1) * #2>, @I$1..@0$1, @I$2..@0$2)); f-3
>
> The same with Emacs Lisp:
>
> | t | y_t | y_{t+1} |
> |---+-----+---------|
> | 1 | 115 | 115.000 |
> | 2 | 121 | 224.500 |
> | 3 | 118 | 320.050 |
> | 4 | 127 | 415.045 |
> #+TBLFM: $3 = '(apply #'+ (cl-mapcar (lambda (tau y-tau) (* (expt 0.9
> (- $1 tau)) y-tau)) '(@I$1..@0$1) '(@I$2..@0$2))); N %.3f
>
> Michael
>
[-- Attachment #2: Type: text/html, Size: 2556 bytes --]
next prev parent reply other threads:[~2017-04-02 17:31 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-30 8:38 Table formula references Manuel Schneckenreither
2017-04-02 17:11 ` Michael Brand
2017-04-02 17:31 ` Manuel Schneckenreither [this message]
[not found] <70b5bcd88f86475cbce6f0a5b1cde9c9@HE1PR01MB1898.eurprd01.prod.exchangelabs.com>
2017-03-30 16:15 ` Eric S Fraga
-- strict thread matches above, loose matches on Subject: below --
2017-03-30 8:37 Manuel Schneckenreither
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CABA4qkcCDAGCc1uXmZykdRAUajNyzZ31O--Bra7Y0fUcGLtksA@mail.gmail.com \
--to=manuel.schnecki@gmail.com \
--cc=emacs-orgmode@gnu.org \
--cc=michael.ch.brand@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).