From: Michael Brand <michael.ch.brand@gmail.com>
To: Manuel Schneckenreither <manuel.schnecki@gmail.com>
Cc: Org Mode <emacs-orgmode@gnu.org>
Subject: Re: Table formula references
Date: Sun, 2 Apr 2017 19:11:15 +0200 [thread overview]
Message-ID: <CALn3zojnOGCe=3U65D8hb4MyA=YKZj+Y=ye_C2EyMmS_YtVJBg@mail.gmail.com> (raw)
In-Reply-To: <8760irgnwj.fsf@uibk.ac.at>
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
next prev parent reply other threads:[~2017-04-02 17:11 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 [this message]
2017-04-02 17:31 ` Manuel Schneckenreither
[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='CALn3zojnOGCe=3U65D8hb4MyA=YKZj+Y=ye_C2EyMmS_YtVJBg@mail.gmail.com' \
--to=michael.ch.brand@gmail.com \
--cc=emacs-orgmode@gnu.org \
--cc=manuel.schnecki@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).