Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
J
Jupyter Angewandte Mathe
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Christian Höfert
Jupyter Angewandte Mathe
Commits
81b41582
Commit
81b41582
authored
Nov 18, 2021
by
Christian Höfert
Browse files
Options
Downloads
Patches
Plain Diff
Update Lineareregression.ipynb
parent
89362e12
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
Lineareregression.ipynb
+1
-1
1 addition, 1 deletion
Lineareregression.ipynb
with
1 addition
and
1 deletion
Lineareregression.ipynb
+
1
−
1
View file @
81b41582
...
@@ -98,7 +98,7 @@
...
@@ -98,7 +98,7 @@
"source": [
"source": [
"N = 100\n",
"N = 100\n",
"nMin = 500\n",
"nMin = 500\n",
"nMax =
40
00\n",
"nMax =
15
00\n",
"\n",
"\n",
"T = np.zeros((2,N))\n",
"T = np.zeros((2,N))\n",
"\n",
"\n",
...
...
...
...
%% Cell type:code id: tags:
%% Cell type:code id: tags:
```
python
```
python
import
numpy
as
np
import
numpy
as
np
import
crh_LinearRegression
as
LinReg
import
crh_LinearRegression
as
LinReg
```
```
%% Cell type:code id: tags:
%% Cell type:code id: tags:
```
python
```
python
"""
"""
Creating random points
Creating random points
"""
"""
n
=
1000
n
=
1000
# reference line
# reference line
m
=
np
.
random
.
rand
()
m
=
np
.
random
.
rand
()
if
np
.
random
.
rand
()
<
.
5
:
if
np
.
random
.
rand
()
<
.
5
:
m
=
-
m
m
=
-
m
c
=
np
.
random
.
rand
()
c
=
np
.
random
.
rand
()
# generating point set
# generating point set
points
=
[[],[]]
points
=
[[],[]]
for
i
in
range
(
n
):
for
i
in
range
(
n
):
x
=
np
.
random
.
rand
()
x
=
np
.
random
.
rand
()
y
=
m
*
x
+
c
+
.
5
*
(
np
.
random
.
rand
()
-
.
5
)
*
np
.
random
.
rand
()
y
=
m
*
x
+
c
+
.
5
*
(
np
.
random
.
rand
()
-
.
5
)
*
np
.
random
.
rand
()
points
[
0
].
append
(
x
)
points
[
0
].
append
(
x
)
points
[
1
].
append
(
y
)
points
[
1
].
append
(
y
)
```
```
%% Cell type:code id: tags:
%% Cell type:code id: tags:
```
python
```
python
"""
"""
Calling regression function
Calling regression function
"""
"""
m
,
c
=
LinReg
.
linearRegression
(
points
[
0
],
points
[
1
],
True
)
m
,
c
=
LinReg
.
linearRegression
(
points
[
0
],
points
[
1
],
True
)
print
(
"
m=
"
,
m
,
"
c=
"
,
c
)
print
(
"
m=
"
,
m
,
"
c=
"
,
c
)
```
```
%% Output
%% Output
m= -0.12246486054984394 c= 0.4159820876090123
m= -0.12246486054984394 c= 0.4159820876090123
%% Cell type:code id: tags:
%% Cell type:code id: tags:
```
python
```
python
import
scipy.linalg
as
lina
import
scipy.linalg
as
lina
import
random
import
random
import
time
import
time
import
math
import
math
```
```
%% Cell type:code id: tags:
%% Cell type:code id: tags:
```
python
```
python
N
=
100
N
=
100
nMin
=
500
nMin
=
500
nMax
=
40
00
nMax
=
15
00
T
=
np
.
zeros
((
2
,
N
))
T
=
np
.
zeros
((
2
,
N
))
for
i
in
range
(
N
):
for
i
in
range
(
N
):
n
=
random
.
randint
(
nMin
,
nMax
)
n
=
random
.
randint
(
nMin
,
nMax
)
A
=
np
.
random
.
rand
(
n
,
n
)
A
=
np
.
random
.
rand
(
n
,
n
)
"""
"""
Determing det(A)
Determing det(A)
"""
"""
start
=
time
.
time
()
start
=
time
.
time
()
D
=
lina
.
det
(
A
)
D
=
lina
.
det
(
A
)
end
=
time
.
time
()
end
=
time
.
time
()
duration
=
end
-
start
duration
=
end
-
start
#print("i:",i, n,duration)
#print("i:",i, n,duration)
print
(
"
\r
"
,
"
Progress:
"
,
i
+
1
,
"
\
"
,
N
,
end
=
""
)
print
(
"
\r
"
,
"
Progress:
"
,
i
+
1
,
"
\
"
,
N
,
end
=
""
)
T
[
0
,
i
]
=
n
T
[
0
,
i
]
=
n
T
[
1
,
i
]
=
duration
T
[
1
,
i
]
=
duration
print
(
"
Done!
"
)
print
(
"
Done!
"
)
```
```
%% Output
%% Output
Progress: 100 \ 100 \ 100
Progress: 100 \ 100 \ 100
%% Cell type:code id: tags:
%% Cell type:code id: tags:
```
python
```
python
#m,c = LinReg.linearRegression([math.log(n) for n in T[0]],[math.log(n) for n in T[1]],True)
#m,c = LinReg.linearRegression([math.log(n) for n in T[0]],[math.log(n) for n in T[1]],True)
m
,
c
=
LinReg
.
linearRegression
(
np
.
log10
(
T
[
0
]),
np
.
log10
(
T
[
1
]),
True
)
m
,
c
=
LinReg
.
linearRegression
(
np
.
log10
(
T
[
0
]),
np
.
log10
(
T
[
1
]),
True
)
print
(
m
,
c
)
print
(
m
,
c
)
LinReg
.
logLinearRegression
(
T
[
0
],
T
[
1
],
True
)
LinReg
.
logLinearRegression
(
T
[
0
],
T
[
1
],
True
)
```
```
%% Output
%% Output
2.656156789776084 -9.603855797451011
2.656156789776084 -9.603855797451011
(2.656156789776084, -9.603855797451011)
(2.656156789776084, -9.603855797451011)
%% Cell type:code id: tags:
%% Cell type:code id: tags:
```
python
```
python
```
```
...
...
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
sign in
to comment