Skip to content

Tool for generating random variables that follows given frequency distibution using linear regressions in given intervals.

License

Notifications You must be signed in to change notification settings

YujiSODE/regLines

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 

Repository files navigation

regLines

Tool for generating random variables that follows given frequency distibution using linear regressions in given intervals.
GitHub: https://github.com/YujiSODE/regLines
Wiki: https://github.com/YujiSODE/regLines/wiki

Copyright (c) 2018 Yuji SODE <yuji.sode@gmail.com>
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"

Input data ranges for linear regressions

Two expressions are available for linear regressions.

  1. dx
    data ranges are defined as v0 v1 ... vn where v0 and vn are the maximum and minimum values.
    vi=v(i-1)+dx and 0<i<n.

  2. x0 x1 ... xn
    data ranges are defined as x0 x1 ... xn.

2. Script

It requires Tcl/Tk 8.6+.

  • regLines.tcl

3. Functions defined by output tcl script file

  • lines(x): function that returns estimated sample distribution
  • linesPDF(x): function that returns a value of probability density function estimated from the sample distribution
  • linesVar(): function that returns a random variable following PDF
    • $x: a numerical value

4. Simplified implementation of linesVar() function

Simplified implementation in Tcl

Simplified implementation in JavaScript

5. Library list