/// <summary>
        /// Computes the standard deviation of the given values.
        /// </summary>
        public static float StandardDeviation(this List<float> values)
        {
            if (values.Count == 0)
                return 0;

            float avg = values.Average();
            // Calculates sum((xi - avg)²)
            float sum = values.ConvertAll(val => (float)Math.Pow(val - avg, 2)).Sum();
            return (float)Math.Sqrt(sum / values.Count);
        }
Ejemplo n.º 2
0
 public static bool WaitAll(this List<IAsyncResult> asyncResults, TimeSpan timeout)
 {
     var waitHandles = asyncResults.ConvertAll(x => x.AsyncWaitHandle);
     return WaitAll(waitHandles.ToArray(), (int)timeout.TotalMilliseconds);
 }
Ejemplo n.º 3
0
		public static string ToCodeString(this List<string> list)
		{
			return "new string[] { " + string.Join(", ", list.ConvertAll((s) => '"' + s + '"')) + " }";
		}
Ejemplo n.º 4
0
 public static List<SquawkListItemViewModel> ConvertToSquawkItemViewModel(this List<Squawk> squawkList)
 {
     return squawkList.ConvertAll(x => new SquawkListItemViewModel()
     {
         Id = x.Id,
         Subject = x.Subject,
         TailNumber = x.Aircraft.RegistrationNumber,
         PostedBy = x.PostedBy.FirstName + " " + x.PostedBy.LastName,
         PostedOn = x.PostedOn,
         Status = x.Status
     });
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Convert list of points to list of xyz's
 /// </summary>
 /// <param name="list">The list to convert</param>
 /// <returns></returns>
 public static List<XYZ> ToXyzs(this List<Autodesk.DesignScript.Geometry.Point> list)
 {
     return list.ConvertAll((x) => new XYZ(x.X, x.Y, x.Z));
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Convert list of points to list of xyz's
 /// </summary>
 /// <param name="list">The list to convert</param>
 /// <returns></returns>
 public static List<Autodesk.DesignScript.Geometry.Point> ToPoints(this List<XYZ> list)
 {
     return list.ConvertAll((x) => Autodesk.DesignScript.Geometry.Point.ByCoordinates(x.X, x.Y, x.Z));
 }
Ejemplo n.º 7
0
 public static List<XYZ> ToXyzs(this List<Autodesk.DesignScript.Geometry.Point> list, bool convertUnits = true)
 {
     return list.ConvertAll((x) => x.ToXyz(convertUnits));
 }
Ejemplo n.º 8
0
 public static List<DC.PlayerMove> ToDataContract(this List<VM.PlayerMove> moves)
 {
     if (moves == null) return new List<DC.PlayerMove>();
     return moves.ConvertAll(ToDataContract);
 }
Ejemplo n.º 9
0
 public static List<TeamListView> ToViewModel(this List<Team> teams)
 {
     return teams.ConvertAll(team => team.ConvertTo<TeamListView>());
 }
Ejemplo n.º 10
0
 public static List<ObjectItem> GetObjects(this List<BankItemRecord> items)
 {
     return items.ConvertAll<ObjectItem>(x => new ObjectItem(63, x.GID, x.GetEffects(), x.UID, x.Quantity));
 }
Ejemplo n.º 11
0
 public static Hatch CreateHatch(this List<Point3d> pts)
 {
     return CreateHatch(pts.ConvertAll(Point3dExtensions.Convert2d));
 }
Ejemplo n.º 12
0
 public static List<ReservationViewModel> ConvertToReservationViewModel(this List<Reservation> reservationList)
 {
     return reservationList.ConvertAll(x => new ReservationViewModel()
     {
         Id = x.Id,
         MemberId = x.MemberId,
         Member = x.Member,
         AircraftId = x.AircraftId,
         Aircraft = x.Aircraft,
         StartDate = x.StartDate,
         StartTime = x.StartDate.ToString("HH:mm"),
         EndDate = x.EndDate,
         EndTime = x.EndDate.ToString("HH:mm")
     });
 }
Ejemplo n.º 13
0
 public static List<VM.PlayerMove> ToViewModel(this List<DC.PlayerMove> moves)
 {
     if(moves == null) return new List<VM.PlayerMove>();
     return moves.ConvertAll(ToViewModel);
 }