Skip to content

Commit

Permalink
Merge pull request #3 from YujiSODE/Y20180301
Browse files Browse the repository at this point in the history
Y20180301
  • Loading branch information
YujiSODE authored Mar 1, 2018
2 parents 3d6d580 + 982324c commit 6ffb5d8
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
20 changes: 19 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,20 @@
# regLines
Tool for generating random variables that follows given frequency distibution using linear regressions in given intervals.
Tool for generating random variables that follows given frequency distibution using linear regressions in given intervals.
GitHub: https://github.com/YujiSODE/regLines
>Copyright (c) 2017 Yuji SODE \<[email protected]\>
>This software is released under the MIT License.
>See LICENSE or http://opensource.org/licenses/mit-license.php
______
## 1. Synopsis
`::regLines::reglines X Y ?name?;`
it outputs tcl script file that defines additional math functions (`lines(x)`, `linesPDF(x)` and `linesVar()`) and returns generated filename
- `$X` and `$Y`: numerical lists for x-axis and y-axis
- `$name`: a text used in order to generate filename of output file, and numbers are default value.
generated filename has a form of `"${name}_regL.tcl"`

## 2. Script
It requires Tcl/Tk 8.6+.
- `regLines.tcl`

## 3. Library list
- lSum/lSum.tcl (Yuji SODE, 2018): https://gist.github.com/YujiSODE/1f9a4e2729212691972b196a76ba9bd0
4 changes: 2 additions & 2 deletions regLines.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ package require Tcl 8.6;
namespace eval ::tcl::mathfunc {
#=== lSum.tcl (Yuji SODE, 2018): https://gist.github.com/YujiSODE/1f9a4e2729212691972b196a76ba9bd0 ===
#it returns sum of given list
#Reference: Iri, M., and Fujino., Y. 1985. Suchi keisan no joshiki (Japanese). Kyoritsu Shuppan Co., Ltd. ISBN 978-4-320-01343-8
#Reference: Iri, M. and Fujino, Y. 1985. Suchi keisan no joshiki (Japanese). Kyoritsu Shuppan Co., Ltd. ISBN 978-4-320-01343-8
proc lSum {list} {
#=== lSum.tcl (Yuji SODE, 2018): https://gist.github.com/YujiSODE/1f9a4e2729212691972b196a76ba9bd0 ===
#Reference: Iri, M., and Fujino., Y. 1985. Suchi keisan no joshiki (Japanese). Kyoritsu Shuppan Co., Ltd. ISBN 978-4-320-01343-8
#Reference: Iri, M. and Fujino, Y. 1985. Suchi keisan no joshiki (Japanese). Kyoritsu Shuppan Co., Ltd. ISBN 978-4-320-01343-8
namespace path {::tcl::mathop};set S 0.0;set R 0.0;set T 0.0;foreach e $list {set R [+ $R [expr double($e)]];set T $S;set S [+ $S $R];set T [+ $S [expr {-$T}]];set R [+ $R [expr {-$T}]];};return $S;
};
#
Expand Down

0 comments on commit 6ffb5d8

Please sign in to comment.