MongoEnumerable.cs 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556
  1. /* Copyright 2015-present MongoDB Inc.
  2. *
  3. * Licensed under the Apache License, Version 2.0 (the "License");
  4. * you may not use this file except in compliance with the License.
  5. * You may obtain a copy of the License at
  6. *
  7. * http://www.apache.org/licenses/LICENSE-2.0
  8. *
  9. * Unless required by applicable law or agreed to in writing, software
  10. * distributed under the License is distributed on an "AS IS" BASIS,
  11. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. * See the License for the specific language governing permissions and
  13. * limitations under the License.
  14. *
  15. */
  16. using System;
  17. using System.Collections.Generic;
  18. using System.Linq;
  19. using MongoDB.Driver.Core.Misc;
  20. namespace MongoDB.Driver.Linq
  21. {
  22. /// <summary>
  23. /// Enumerable Extensions for MongoDB.
  24. /// </summary>
  25. public static class MongoEnumerable
  26. {
  27. internal static HashSet<T> ToHashSet<T>(this IEnumerable<T> source)
  28. {
  29. Ensure.IsNotNull(source, nameof(source));
  30. return new HashSet<T>(source);
  31. }
  32. /// <summary>
  33. /// Computes the population standard deviation of a sequence of values.
  34. /// </summary>
  35. /// <param name="source">A sequence of values to calculate the population standard deviation of.</param>
  36. /// <returns>
  37. /// The population standard deviation of the sequence of values.
  38. /// </returns>
  39. public static double StandardDeviationPopulation(this IEnumerable<int> source)
  40. {
  41. throw new NotSupportedException("This method is not functional. It is only usable in conjunction with MongoDB.");
  42. }
  43. /// <summary>
  44. /// Computes the population standard deviation of a sequence of values.
  45. /// </summary>
  46. /// <param name="source">A sequence of values to calculate the population standard deviation of.</param>
  47. /// <returns>
  48. /// The population standard deviation of the sequence of values.
  49. /// </returns>
  50. public static double? StandardDeviationPopulation(this IEnumerable<int?> source)
  51. {
  52. throw new NotSupportedException("This method is not functional. It is only usable in conjunction with MongoDB.");
  53. }
  54. /// <summary>
  55. /// Computes the population standard deviation of a sequence of values.
  56. /// </summary>
  57. /// <param name="source">A sequence of values to calculate the population standard deviation of.</param>
  58. /// <returns>
  59. /// The population standard deviation of the sequence of values.
  60. /// </returns>
  61. public static double StandardDeviationPopulation(this IEnumerable<long> source)
  62. {
  63. throw new NotSupportedException("This method is not functional. It is only usable in conjunction with MongoDB.");
  64. }
  65. /// <summary>
  66. /// Computes the population standard deviation of a sequence of values.
  67. /// </summary>
  68. /// <param name="source">A sequence of values to calculate the population standard deviation of.</param>
  69. /// <returns>
  70. /// The population standard deviation of the sequence of values.
  71. /// </returns>
  72. public static double? StandardDeviationPopulation(this IEnumerable<long?> source)
  73. {
  74. throw new NotSupportedException("This method is not functional. It is only usable in conjunction with MongoDB.");
  75. }
  76. /// <summary>
  77. /// Computes the population standard deviation of a sequence of values.
  78. /// </summary>
  79. /// <param name="source">A sequence of values to calculate the population standard deviation of.</param>
  80. /// <returns>
  81. /// The population standard deviation of the sequence of values.
  82. /// </returns>
  83. public static float StandardDeviationPopulation(this IEnumerable<float> source)
  84. {
  85. throw new NotSupportedException("This method is not functional. It is only usable in conjunction with MongoDB.");
  86. }
  87. /// <summary>
  88. /// Computes the population standard deviation of a sequence of values.
  89. /// </summary>
  90. /// <param name="source">A sequence of values to calculate the population standard deviation of.</param>
  91. /// <returns>
  92. /// The population standard deviation of the sequence of values.
  93. /// </returns>
  94. public static float? StandardDeviationPopulation(this IEnumerable<float?> source)
  95. {
  96. throw new NotSupportedException("This method is not functional. It is only usable in conjunction with MongoDB.");
  97. }
  98. /// <summary>
  99. /// Computes the population standard deviation of a sequence of values.
  100. /// </summary>
  101. /// <param name="source">A sequence of values to calculate the population standard deviation of.</param>
  102. /// <returns>
  103. /// The population standard deviation of the sequence of values.
  104. /// </returns>
  105. public static double StandardDeviationPopulation(this IEnumerable<double> source)
  106. {
  107. throw new NotSupportedException("This method is not functional. It is only usable in conjunction with MongoDB.");
  108. }
  109. /// <summary>
  110. /// Computes the population standard deviation of a sequence of values.
  111. /// </summary>
  112. /// <param name="source">A sequence of values to calculate the population standard deviation of.</param>
  113. /// <returns>
  114. /// The population standard deviation of the sequence of values.
  115. /// </returns>
  116. public static double? StandardDeviationPopulation(this IEnumerable<double?> source)
  117. {
  118. throw new NotSupportedException("This method is not functional. It is only usable in conjunction with MongoDB.");
  119. }
  120. /// <summary>
  121. /// Computes the population standard deviation of a sequence of values.
  122. /// </summary>
  123. /// <param name="source">A sequence of values to calculate the population standard deviation of.</param>
  124. /// <returns>
  125. /// The population standard deviation of the sequence of values.
  126. /// </returns>
  127. public static decimal StandardDeviationPopulation(this IEnumerable<decimal> source)
  128. {
  129. throw new NotSupportedException("This method is not functional. It is only usable in conjunction with MongoDB.");
  130. }
  131. /// <summary>
  132. /// Computes the population standard deviation of a sequence of values.
  133. /// </summary>
  134. /// <param name="source">A sequence of values to calculate the population standard deviation of.</param>
  135. /// <returns>
  136. /// The population standard deviation of the sequence of values.
  137. /// </returns>
  138. public static decimal? StandardDeviationPopulation(this IEnumerable<decimal?> source)
  139. {
  140. throw new NotSupportedException("This method is not functional. It is only usable in conjunction with MongoDB.");
  141. }
  142. /// <summary>
  143. /// Computes the population standard deviation of a sequence of values that are obtained by invoking a transform function on each element of the input sequence.
  144. /// </summary>
  145. /// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
  146. /// <param name="source">A sequence of values to calculate the population standard deviation of.</param>
  147. /// <param name="selector">A transform function to apply to each element.</param>
  148. /// <returns>
  149. /// The population standard deviation of the sequence of values.
  150. /// </returns>
  151. public static double StandardDeviationPopulation<TSource>(this IEnumerable<TSource> source, Func<TSource, int> selector)
  152. {
  153. return source.Select(selector).StandardDeviationPopulation();
  154. }
  155. /// <summary>
  156. /// Computes the population standard deviation of a sequence of values that are obtained by invoking a transform function on each element of the input sequence.
  157. /// </summary>
  158. /// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
  159. /// <param name="source">A sequence of values to calculate the population standard deviation of.</param>
  160. /// <param name="selector">A transform function to apply to each element.</param>
  161. /// <returns>
  162. /// The population standard deviation of the sequence of values.
  163. /// </returns>
  164. public static double? StandardDeviationPopulation<TSource>(this IEnumerable<TSource> source, Func<TSource, int?> selector)
  165. {
  166. return source.Select(selector).StandardDeviationPopulation();
  167. }
  168. /// <summary>
  169. /// Computes the population standard deviation of a sequence of values that are obtained by invoking a transform function on each element of the input sequence.
  170. /// </summary>
  171. /// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
  172. /// <param name="source">A sequence of values to calculate the population standard deviation of.</param>
  173. /// <param name="selector">A transform function to apply to each element.</param>
  174. /// <returns>
  175. /// The population standard deviation of the sequence of values.
  176. /// </returns>
  177. public static double StandardDeviationPopulation<TSource>(this IEnumerable<TSource> source, Func<TSource, long> selector)
  178. {
  179. return source.Select(selector).StandardDeviationPopulation();
  180. }
  181. /// <summary>
  182. /// Computes the population standard deviation of a sequence of values that are obtained by invoking a transform function on each element of the input sequence.
  183. /// </summary>
  184. /// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
  185. /// <param name="source">A sequence of values to calculate the population standard deviation of.</param>
  186. /// <param name="selector">A transform function to apply to each element.</param>
  187. /// <returns>
  188. /// The population standard deviation of the sequence of values.
  189. /// </returns>
  190. public static double? StandardDeviationPopulation<TSource>(this IEnumerable<TSource> source, Func<TSource, long?> selector)
  191. {
  192. return source.Select(selector).StandardDeviationPopulation();
  193. }
  194. /// <summary>
  195. /// Computes the population standard deviation of a sequence of values that are obtained by invoking a transform function on each element of the input sequence.
  196. /// </summary>
  197. /// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
  198. /// <param name="source">A sequence of values to calculate the population standard deviation of.</param>
  199. /// <param name="selector">A transform function to apply to each element.</param>
  200. /// <returns>
  201. /// The population standard deviation of the sequence of values.
  202. /// </returns>
  203. public static float StandardDeviationPopulation<TSource>(this IEnumerable<TSource> source, Func<TSource, float> selector)
  204. {
  205. return source.Select(selector).StandardDeviationPopulation();
  206. }
  207. /// <summary>
  208. /// Computes the population standard deviation of a sequence of values that are obtained by invoking a transform function on each element of the input sequence.
  209. /// </summary>
  210. /// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
  211. /// <param name="source">A sequence of values to calculate the population standard deviation of.</param>
  212. /// <param name="selector">A transform function to apply to each element.</param>
  213. /// <returns>
  214. /// The population standard deviation of the sequence of values.
  215. /// </returns>
  216. public static float? StandardDeviationPopulation<TSource>(this IEnumerable<TSource> source, Func<TSource, float?> selector)
  217. {
  218. return source.Select(selector).StandardDeviationPopulation();
  219. }
  220. /// <summary>
  221. /// Computes the population standard deviation of a sequence of values that are obtained by invoking a transform function on each element of the input sequence.
  222. /// </summary>
  223. /// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
  224. /// <param name="source">A sequence of values to calculate the population standard deviation of.</param>
  225. /// <param name="selector">A transform function to apply to each element.</param>
  226. /// <returns>
  227. /// The population standard deviation of the sequence of values.
  228. /// </returns>
  229. public static double StandardDeviationPopulation<TSource>(this IEnumerable<TSource> source, Func<TSource, double> selector)
  230. {
  231. return source.Select(selector).StandardDeviationPopulation();
  232. }
  233. /// <summary>
  234. /// Computes the population standard deviation of a sequence of values that are obtained by invoking a transform function on each element of the input sequence.
  235. /// </summary>
  236. /// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
  237. /// <param name="source">A sequence of values to calculate the population standard deviation of.</param>
  238. /// <param name="selector">A transform function to apply to each element.</param>
  239. /// <returns>
  240. /// The population standard deviation of the sequence of values.
  241. /// </returns>
  242. public static double? StandardDeviationPopulation<TSource>(this IEnumerable<TSource> source, Func<TSource, double?> selector)
  243. {
  244. return source.Select(selector).StandardDeviationPopulation();
  245. }
  246. /// <summary>
  247. /// Computes the population standard deviation of a sequence of values that are obtained by invoking a transform function on each element of the input sequence.
  248. /// </summary>
  249. /// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
  250. /// <param name="source">A sequence of values to calculate the population standard deviation of.</param>
  251. /// <param name="selector">A transform function to apply to each element.</param>
  252. /// <returns>
  253. /// The population standard deviation of the sequence of values.
  254. /// </returns>
  255. public static decimal StandardDeviationPopulation<TSource>(this IEnumerable<TSource> source, Func<TSource, decimal> selector)
  256. {
  257. return source.Select(selector).StandardDeviationPopulation();
  258. }
  259. /// <summary>
  260. /// Computes the population standard deviation of a sequence of values that are obtained by invoking a transform function on each element of the input sequence.
  261. /// </summary>
  262. /// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
  263. /// <param name="source">A sequence of values to calculate the population standard deviation of.</param>
  264. /// <param name="selector">A transform function to apply to each element.</param>
  265. /// <returns>
  266. /// The population standard deviation of the sequence of values.
  267. /// </returns>
  268. public static decimal? StandardDeviationPopulation<TSource>(this IEnumerable<TSource> source, Func<TSource, decimal?> selector)
  269. {
  270. return source.Select(selector).StandardDeviationPopulation();
  271. }
  272. /// <summary>
  273. /// Computes the sample standard deviation of a sequence of values.
  274. /// </summary>
  275. /// <param name="source">A sequence of values to calculate the population standard deviation of.</param>
  276. /// <returns>
  277. /// The population standard deviation of the sequence of values.
  278. /// </returns>
  279. public static double StandardDeviationSample(this IEnumerable<int> source)
  280. {
  281. throw new NotSupportedException("This method is not functional. It is only usable in conjunction with MongoDB.");
  282. }
  283. /// <summary>
  284. /// Computes the sample standard deviation of a sequence of values.
  285. /// </summary>
  286. /// <param name="source">A sequence of values to calculate the population standard deviation of.</param>
  287. /// <returns>
  288. /// The population standard deviation of the sequence of values.
  289. /// </returns>
  290. public static double? StandardDeviationSample(this IEnumerable<int?> source)
  291. {
  292. throw new NotSupportedException("This method is not functional. It is only usable in conjunction with MongoDB.");
  293. }
  294. /// <summary>
  295. /// Computes the sample standard deviation of a sequence of values.
  296. /// </summary>
  297. /// <param name="source">A sequence of values to calculate the population standard deviation of.</param>
  298. /// <returns>
  299. /// The population standard deviation of the sequence of values.
  300. /// </returns>
  301. public static double StandardDeviationSample(this IEnumerable<long> source)
  302. {
  303. throw new NotSupportedException("This method is not functional. It is only usable in conjunction with MongoDB.");
  304. }
  305. /// <summary>
  306. /// Computes the sample standard deviation of a sequence of values.
  307. /// </summary>
  308. /// <param name="source">A sequence of values to calculate the population standard deviation of.</param>
  309. /// <returns>
  310. /// The population standard deviation of the sequence of values.
  311. /// </returns>
  312. public static double? StandardDeviationSample(this IEnumerable<long?> source)
  313. {
  314. throw new NotSupportedException("This method is not functional. It is only usable in conjunction with MongoDB.");
  315. }
  316. /// <summary>
  317. /// Computes the sample standard deviation of a sequence of values.
  318. /// </summary>
  319. /// <param name="source">A sequence of values to calculate the population standard deviation of.</param>
  320. /// <returns>
  321. /// The population standard deviation of the sequence of values.
  322. /// </returns>
  323. public static float StandardDeviationSample(this IEnumerable<float> source)
  324. {
  325. throw new NotSupportedException("This method is not functional. It is only usable in conjunction with MongoDB.");
  326. }
  327. /// <summary>
  328. /// Computes the sample standard deviation of a sequence of values.
  329. /// </summary>
  330. /// <param name="source">A sequence of values to calculate the population standard deviation of.</param>
  331. /// <returns>
  332. /// The population standard deviation of the sequence of values.
  333. /// </returns>
  334. public static float? StandardDeviationSample(this IEnumerable<float?> source)
  335. {
  336. throw new NotSupportedException("This method is not functional. It is only usable in conjunction with MongoDB.");
  337. }
  338. /// <summary>
  339. /// Computes the sample standard deviation of a sequence of values.
  340. /// </summary>
  341. /// <param name="source">A sequence of values to calculate the population standard deviation of.</param>
  342. /// <returns>
  343. /// The population standard deviation of the sequence of values.
  344. /// </returns>
  345. public static double StandardDeviationSample(this IEnumerable<double> source)
  346. {
  347. throw new NotSupportedException("This method is not functional. It is only usable in conjunction with MongoDB.");
  348. }
  349. /// <summary>
  350. /// Computes the sample standard deviation of a sequence of values.
  351. /// </summary>
  352. /// <param name="source">A sequence of values to calculate the population standard deviation of.</param>
  353. /// <returns>
  354. /// The population standard deviation of the sequence of values.
  355. /// </returns>
  356. public static double? StandardDeviationSample(this IEnumerable<double?> source)
  357. {
  358. throw new NotSupportedException("This method is not functional. It is only usable in conjunction with MongoDB.");
  359. }
  360. /// <summary>
  361. /// Computes the sample standard deviation of a sequence of values.
  362. /// </summary>
  363. /// <param name="source">A sequence of values to calculate the population standard deviation of.</param>
  364. /// <returns>
  365. /// The population standard deviation of the sequence of values.
  366. /// </returns>
  367. public static decimal StandardDeviationSample(this IEnumerable<decimal> source)
  368. {
  369. throw new NotSupportedException("This method is not functional. It is only usable in conjunction with MongoDB.");
  370. }
  371. /// <summary>
  372. /// Computes the sample standard deviation of a sequence of values.
  373. /// </summary>
  374. /// <param name="source">A sequence of values to calculate the population standard deviation of.</param>
  375. /// <returns>
  376. /// The population standard deviation of the sequence of values.
  377. /// </returns>
  378. public static decimal? StandardDeviationSample(this IEnumerable<decimal?> source)
  379. {
  380. throw new NotSupportedException("This method is not functional. It is only usable in conjunction with MongoDB.");
  381. }
  382. /// <summary>
  383. /// Computes the sample standard deviation of a sequence of values that are obtained by invoking a transform function on each element of the input sequence.
  384. /// </summary>
  385. /// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
  386. /// <param name="source">A sequence of values to calculate the population standard deviation of.</param>
  387. /// <param name="selector">A transform function to apply to each element.</param>
  388. /// <returns>
  389. /// The population standard deviation of the sequence of values.
  390. /// </returns>
  391. public static double StandardDeviationSample<TSource>(this IEnumerable<TSource> source, Func<TSource, int> selector)
  392. {
  393. return source.Select(selector).StandardDeviationSample();
  394. }
  395. /// <summary>
  396. /// Computes the sample standard deviation of a sequence of values that are obtained by invoking a transform function on each element of the input sequence.
  397. /// </summary>
  398. /// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
  399. /// <param name="source">A sequence of values to calculate the population standard deviation of.</param>
  400. /// <param name="selector">A transform function to apply to each element.</param>
  401. /// <returns>
  402. /// The population standard deviation of the sequence of values.
  403. /// </returns>
  404. public static double? StandardDeviationSample<TSource>(this IEnumerable<TSource> source, Func<TSource, int?> selector)
  405. {
  406. return source.Select(selector).StandardDeviationSample();
  407. }
  408. /// <summary>
  409. /// Computes the sample standard deviation of a sequence of values that are obtained by invoking a transform function on each element of the input sequence.
  410. /// </summary>
  411. /// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
  412. /// <param name="source">A sequence of values to calculate the population standard deviation of.</param>
  413. /// <param name="selector">A transform function to apply to each element.</param>
  414. /// <returns>
  415. /// The population standard deviation of the sequence of values.
  416. /// </returns>
  417. public static double StandardDeviationSample<TSource>(this IEnumerable<TSource> source, Func<TSource, long> selector)
  418. {
  419. return source.Select(selector).StandardDeviationSample();
  420. }
  421. /// <summary>
  422. /// Computes the sample standard deviation of a sequence of values that are obtained by invoking a transform function on each element of the input sequence.
  423. /// </summary>
  424. /// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
  425. /// <param name="source">A sequence of values to calculate the population standard deviation of.</param>
  426. /// <param name="selector">A transform function to apply to each element.</param>
  427. /// <returns>
  428. /// The population standard deviation of the sequence of values.
  429. /// </returns>
  430. public static double? StandardDeviationSample<TSource>(this IEnumerable<TSource> source, Func<TSource, long?> selector)
  431. {
  432. return source.Select(selector).StandardDeviationSample();
  433. }
  434. /// <summary>
  435. /// Computes the sample standard deviation of a sequence of values that are obtained by invoking a transform function on each element of the input sequence.
  436. /// </summary>
  437. /// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
  438. /// <param name="source">A sequence of values to calculate the population standard deviation of.</param>
  439. /// <param name="selector">A transform function to apply to each element.</param>
  440. /// <returns>
  441. /// The population standard deviation of the sequence of values.
  442. /// </returns>
  443. public static float StandardDeviationSample<TSource>(this IEnumerable<TSource> source, Func<TSource, float> selector)
  444. {
  445. return source.Select(selector).StandardDeviationSample();
  446. }
  447. /// <summary>
  448. /// Computes the sample standard deviation of a sequence of values that are obtained by invoking a transform function on each element of the input sequence.
  449. /// </summary>
  450. /// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
  451. /// <param name="source">A sequence of values to calculate the population standard deviation of.</param>
  452. /// <param name="selector">A transform function to apply to each element.</param>
  453. /// <returns>
  454. /// The population standard deviation of the sequence of values.
  455. /// </returns>
  456. public static float? StandardDeviationSample<TSource>(this IEnumerable<TSource> source, Func<TSource, float?> selector)
  457. {
  458. return source.Select(selector).StandardDeviationSample();
  459. }
  460. /// <summary>
  461. /// Computes the sample standard deviation of a sequence of values that are obtained by invoking a transform function on each element of the input sequence.
  462. /// </summary>
  463. /// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
  464. /// <param name="source">A sequence of values to calculate the population standard deviation of.</param>
  465. /// <param name="selector">A transform function to apply to each element.</param>
  466. /// <returns>
  467. /// The population standard deviation of the sequence of values.
  468. /// </returns>
  469. public static double StandardDeviationSample<TSource>(this IEnumerable<TSource> source, Func<TSource, double> selector)
  470. {
  471. return source.Select(selector).StandardDeviationSample();
  472. }
  473. /// <summary>
  474. /// Computes the sample standard deviation of a sequence of values that are obtained by invoking a transform function on each element of the input sequence.
  475. /// </summary>
  476. /// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
  477. /// <param name="source">A sequence of values to calculate the population standard deviation of.</param>
  478. /// <param name="selector">A transform function to apply to each element.</param>
  479. /// <returns>
  480. /// The population standard deviation of the sequence of values.
  481. /// </returns>
  482. public static double? StandardDeviationSample<TSource>(this IEnumerable<TSource> source, Func<TSource, double?> selector)
  483. {
  484. return source.Select(selector).StandardDeviationSample();
  485. }
  486. /// <summary>
  487. /// Computes the sample standard deviation of a sequence of values that are obtained by invoking a transform function on each element of the input sequence.
  488. /// </summary>
  489. /// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
  490. /// <param name="source">A sequence of values to calculate the population standard deviation of.</param>
  491. /// <param name="selector">A transform function to apply to each element.</param>
  492. /// <returns>
  493. /// The population standard deviation of the sequence of values.
  494. /// </returns>
  495. public static decimal StandardDeviationSample<TSource>(this IEnumerable<TSource> source, Func<TSource, decimal> selector)
  496. {
  497. return source.Select(selector).StandardDeviationSample();
  498. }
  499. /// <summary>
  500. /// Computes the sample standard deviation of a sequence of values that are obtained by invoking a transform function on each element of the input sequence.
  501. /// </summary>
  502. /// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
  503. /// <param name="source">A sequence of values to calculate the population standard deviation of.</param>
  504. /// <param name="selector">A transform function to apply to each element.</param>
  505. /// <returns>
  506. /// The population standard deviation of the sequence of values.
  507. /// </returns>
  508. public static decimal? StandardDeviationSample<TSource>(this IEnumerable<TSource> source, Func<TSource, decimal?> selector)
  509. {
  510. return source.Select(selector).StandardDeviationSample();
  511. }
  512. }
  513. }