Popular Python recipes tagged "linear"http://code.activestate.com/recipes/langs/python/tags/linear/2012-05-12T13:36:55-07:00ActiveState Code RecipesSimple linear regression (Python)
2012-05-12T13:36:55-07:00Thomas Lehmannhttp://code.activestate.com/recipes/users/4174477/http://code.activestate.com/recipes/578129-simple-linear-regression/
<p style="color: grey">
Python
recipe 578129
by <a href="/recipes/users/4174477/">Thomas Lehmann</a>
(<a href="/recipes/tags/decrease/">decrease</a>, <a href="/recipes/tags/increase/">increase</a>, <a href="/recipes/tags/linear/">linear</a>, <a href="/recipes/tags/math/">math</a>, <a href="/recipes/tags/percental/">percental</a>, <a href="/recipes/tags/regression/">regression</a>, <a href="/recipes/tags/simple/">simple</a>).
Revision 3.
</p>
<p><strong>What?</strong></p>
<ul>
<li>It's about forecasting.</li>
<li>It's about calculating a linear function.</li>
<li><em>Details I found</em>: <a href="http://www.faes.de/Basis/Basis-Statistik/Basis-Statistik-Korrelation-Re/basis-statistik-korrelation-re.html" rel="nofollow">http://www.faes.de/Basis/Basis-Statistik/Basis-Statistik-Korrelation-Re/basis-statistik-korrelation-re.html</a> (in german)</li>
</ul>
<p>Also I don't know how the formula have been created the practical part was very easy to me. I have verified one example (see code) using Open Office Calc (I've learned: you can display the formula for the trend line as well as the coefficient of correlation - great).</p>
<p><strong>Why?</strong></p>
<ul>
<li>In <a href="http://code.activestate.com/recipes/578111/">recipe 578111</a> I'm printing out current error rate for different training sessions in mental arithmetic.</li>
<li>Anyway I would like to be able to given information - approximately - about how many you have improved since you train yourself.</li>
</ul>
<p><strong>What has changed?</strong></p>
<ul>
<li><strong>Revision2</strong>: Didn't compile with Jython 2.5.3b1 because of not supported exception syntax. Now it does work without exception.</li>
<li><strong>Revision3</strong>: Test data row for failure not removed.</li>
</ul>
Silmultaneous linear equation solver(any order) (Python)
2012-04-24T12:29:30-07:00Sachin Joglekarhttp://code.activestate.com/recipes/users/4181845/http://code.activestate.com/recipes/578109-silmultaneous-linear-equation-solverany-order/
<p style="color: grey">
Python
recipe 578109
by <a href="/recipes/users/4181845/">Sachin Joglekar</a>
(<a href="/recipes/tags/algebra/">algebra</a>, <a href="/recipes/tags/crammer/">crammer</a>, <a href="/recipes/tags/determinants/">determinants</a>, <a href="/recipes/tags/equation/">equation</a>, <a href="/recipes/tags/linear/">linear</a>, <a href="/recipes/tags/simultaneous/">simultaneous</a>).
</p>
<p>Solves simultaneous linear equations of any order using Crammer's rule. Required input is two lists..one for coefficients, and other for constants
eg. 2x+3y=8
x+4y=6 will be written as
simul([[2,3],[1,4]],[8,6])</p>
Class to calculate increment of variables based on time (units per seconds) (Python)
2008-08-18T16:29:08-07:00nosklohttp://code.activestate.com/recipes/users/4166478/http://code.activestate.com/recipes/576424-class-to-calculate-increment-of-variables-based-on/
<p style="color: grey">
Python
recipe 576424
by <a href="/recipes/users/4166478/">nosklo</a>
(<a href="/recipes/tags/increment/">increment</a>, <a href="/recipes/tags/linear/">linear</a>, <a href="/recipes/tags/number/">number</a>, <a href="/recipes/tags/time/">time</a>, <a href="/recipes/tags/units_per_second/">units_per_second</a>, <a href="/recipes/tags/variables/">variables</a>).
Revision 3.
</p>
<p>A simple calculation of small increments to be applied to a variable, given the variable time that has passed since last update, to make a linear increase over time (in units per second).</p>