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
998a5713
Commit
998a5713
authored
May 26, 2022
by
潘栩锋
🚴
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MyMath 添加 double Sigma(IEnumerable<double> buf, int first, int last)
parent
854d1a38
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
0 deletions
+28
-0
MyMath.cs
Project.FLY.Misc/MISC/MyMath.cs
+28
-0
No files found.
Project.FLY.Misc/MISC/MyMath.cs
View file @
998a5713
...
@@ -274,7 +274,35 @@ namespace Misc
...
@@ -274,7 +274,35 @@ namespace Misc
else
else
return
0
;
return
0
;
}
}
/// <summary>
/// 排除 NULL_VALUE, 求Sigma
/// </summary>
/// <param name="buf"></param>
/// <param name="first">开始序号</param>
/// <param name="last">结束序号</param>
/// <returns></returns>
public
static
double
Sigma
(
IEnumerable
<
double
>
buf
,
int
first
,
int
last
)
{
double
avg
=
Avg
(
buf
,
first
,
last
);
if
(
double
.
IsNaN
(
avg
))
return
double
.
NaN
;
double
sum
=
0
;
int
cnt
=
0
;
for
(
int
i
=
first
;
i
<=
last
;
i
++)
{
if
(!
double
.
IsNaN
(
buf
.
ElementAt
(
i
)))
{
sum
+=
(
buf
.
ElementAt
(
i
)
-
avg
)
*
(
buf
.
ElementAt
(
i
)
-
avg
);
cnt
++;
}
}
if
(
cnt
>=
3
)
return
(
Math
.
Sqrt
(
sum
/
(
cnt
-
1
)));
else
return
0
;
}
/// <summary>
/// <summary>
/// 排除 NULL_VALUE, 求Sigma
/// 排除 NULL_VALUE, 求Sigma
/// </summary>
/// </summary>
...
...
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