HoloLens 2 Gait Training
The purpose of this project is to create gait training application.
Loading...
Searching...
No Matches
GaussianDistribution.cs
Go to the documentation of this file.
1
2using System.Collections;
3using System.Collections.Generic;
4using UnityEngine;
5using System;
6
12public class GaussianDistribution : System.Random
13{
14 private double u1;
15 private double u2;
16 private double temp1;
17 private double temp2;
18
19 public GaussianDistribution( int seed ) : base( seed )
20 {
21 }
22
23 public GaussianDistribution() : base()
24 {
25 }
26
35 public double RandomGauss( double mu = 0, double sigma = 1 )
36 {
37 if (sigma <= 0)
38 throw new ArgumentOutOfRangeException("sigma", "Must be greater than zero.");
39
40 u1 = base.NextDouble();
41 u2 = base.NextDouble();
42 temp1 = Math.Sqrt( -2 * Math.Log( u1 ) );
43 temp2 = 2 * Math.PI * u2;
44
45 return mu + sigma * ( temp1 * Math.Cos( temp2 ) );
46 }
47
48}
Takes two uniformly distributed deviates within the unit circle, and transforms them into two indepen...
double RandomGauss(double mu=0, double sigma=1)
Obtains normally (Gaussian) distrubuted random numbers, using the Box-Muller transformation....