Initial
This commit is contained in:
		
							parent
							
								
									43df57b1a1
								
							
						
					
					
						commit
						14ea7dac4a
					
				
							
								
								
									
										20
									
								
								FastRng/Double/Distributions/ChiSquare.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										20
									
								
								FastRng/Double/Distributions/ChiSquare.cs
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,20 @@
 | 
				
			|||||||
 | 
					using System.Threading;
 | 
				
			||||||
 | 
					using System.Threading.Tasks;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace FastRng.Double.Distributions
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    public sealed class ChiSquare : IDistribution
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        public IRandom Random { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public double DegreesOfFreedom { get; set; } = 1.0;
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        public async ValueTask<double> GetDistributedValue(CancellationToken token)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            if (this.Random == null)
 | 
				
			||||||
 | 
					                return 0.0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            return await this.Random.NextNumber(new Gamma{ Shape = 0.5 * this.DegreesOfFreedom, Scale = 2.0 }, token);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user