Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
W
WindEnergyToolbox
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
wtlib
WindEnergyToolbox
Commits
5dcfbcd5
Commit
5dcfbcd5
authored
8 years ago
by
Mads M. Pedersen
Browse files
Options
Downloads
Patches
Plain Diff
test weibull
parent
0c655e3a
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
wetb/wind/tests/test_weibull.py
+57
-0
57 additions, 0 deletions
wetb/wind/tests/test_weibull.py
with
57 additions
and
0 deletions
wetb/wind/tests/test_weibull.py
0 → 100644
+
57
−
0
View file @
5dcfbcd5
'''
Created on 04/12/2015
@author: mmpe
'''
import
unittest
import
matplotlib.pyplot
as
plt
import
numpy
as
np
from
wetb.wind
import
weibull
class
TestWeibull
(
unittest
.
TestCase
):
def
test_weibull
(
self
):
wb
=
weibull
.
pdf
(
4
,
2
)
x
=
np
.
arange
(
0
,
20
,
.
1
)
self
.
assertAlmostEqual
(
wb
(
x
).
max
(),
0.21441923796454562
)
if
0
:
plt
.
plot
(
x
,
wb
(
x
))
plt
.
show
()
def
test_random_weibull
(
self
):
y
=
weibull
.
random
(
4
,
2
,
1000000
)
pdf
,
x
=
np
.
histogram
(
y
,
100
,
normed
=
True
)
x
=
(
x
[
1
:]
+
x
[:
-
1
])
/
2
self
.
assertLess
(
sum
((
pdf
-
weibull
.
pdf
(
4
,
2
)(
x
))
**
2
),
0.0001
)
if
0
:
plt
.
plot
(
x
,
pdf
)
plt
.
plot
(
x
,
weibull
.
pdf
(
4
,
2
)(
x
))
plt
.
show
()
def
test_fit_weibull
(
self
):
y
=
weibull
.
random
(
4
,
2
,
1000000
)
A
,
k
=
weibull
.
fit
(
y
)
self
.
assertAlmostEqual
(
A
,
4
,
delta
=
0.01
)
self
.
assertAlmostEqual
(
k
,
2
,
delta
=
0.01
)
if
0
:
plt
.
hist
(
y
,
100
,
normed
=
True
)
x
=
np
.
arange
(
0
,
20
,
.
1
)
plt
.
plot
(
x
,
weibull
.
pdf
(
4
,
2
)(
x
))
plt
.
show
()
def
test_weibull_cdf
(
self
):
wb
=
weibull
.
pdf
(
4
,
2
)
x
=
np
.
arange
(
0
,
20
,
.
01
)
cdf
=
weibull
.
cdf
(
4
,
2
)
self
.
assertEqual
(
cdf
(
999
),
1
)
np
.
testing
.
assert_array_almost_equal
(
np
.
cumsum
(
wb
(
x
))
/
100
,
cdf
(
x
),
3
)
if
0
:
plt
.
plot
(
x
,
np
.
cumsum
(
wb
(
x
))
*
.
01
)
plt
.
plot
(
x
,
cdf
(
x
))
plt
.
show
()
if
__name__
==
"
__main__
"
:
#import sys;sys.argv = ['', 'Test.testweibull']
unittest
.
main
()
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
register
or
sign in
to comment