Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
T
Thick-Common
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
潘栩锋
Thick-Common
Commits
2d95cf90
Commit
2d95cf90
authored
Jul 31, 2021
by
潘栩锋
🚴
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加 MISC/Enumerable.cs 添加 平滑函数
parent
2c1358f2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
45 additions
and
0 deletions
+45
-0
Enumerable.cs
Project.FLY.Misc/MISC/Enumerable.cs
+45
-0
No files found.
Project.FLY.Misc/MISC/Enumerable.cs
View file @
2d95cf90
...
@@ -212,6 +212,51 @@ namespace Misc
...
@@ -212,6 +212,51 @@ namespace Misc
}
}
return
System
.
Linq
.
Enumerable
.
SequenceEqual
(
first
,
second
,
comparer
);
return
System
.
Linq
.
Enumerable
.
SequenceEqual
(
first
,
second
,
comparer
);
}
}
/// <summary>
/// 对数列平滑;
/// 数列的两端,平滑量只有 radius;中间数据平滑量 = radius*2+1
/// </summary>
/// <param name="data">数列</param>
/// <param name="radius">平滑半径</param>
/// <returns></returns>
public
static
double
[]
Smooth
(
this
IEnumerable
<
double
>
frame
,
int
radius
)
{
if
(
radius
>
0
)
{
double
[]
frame2
=
new
double
[
frame
.
Count
()];
for
(
int
i
=
0
;
i
<
frame
.
Count
();
i
++)
{
double
sum
=
0
;
int
cnt
=
0
;
int
index_b
=
i
-
radius
;
int
index_e
=
i
+
radius
;
for
(
int
j
=
index_b
;
j
<=
index_e
;
j
++)
{
if
((
j
>=
0
)
&&
(
j
<
frame
.
Count
()))
{
double
v
=
frame
.
ElementAt
(
j
);
if
(!
double
.
IsNaN
(
v
))
{
sum
+=
v
;
cnt
++;
}
}
}
if
(
cnt
>
0
)
frame2
[
i
]
=
sum
/
cnt
;
else
frame2
[
i
]
=
double
.
NaN
;
}
return
frame2
;
}
else
{
return
frame
.
ToArray
();
}
}
}
}
/// <summary>
/// <summary>
/// X Y 组合
/// X Y 组合
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment