50 lines
1.7 KiB
C#
50 lines
1.7 KiB
C#
using Enigmos.Ports.DataPorts;
|
|
using Nocturnis.DataStructures.ConfigurableParameters;
|
|
using Nocturnis.Enigmos.Modules;
|
|
using Nocturnis.Enigmos.Modules.ComputationalModules;
|
|
using Nocturnis.Enigmos.Ports;
|
|
using Nocturnis.Enigmos.Ports.DataPorts.Directions;
|
|
using Nocturnis.GlobalManagement.Constants;
|
|
using Nocturnis.GlobalManagement.Providers;
|
|
using Skeleton.Utils.RandomEngines;
|
|
|
|
|
|
namespace Enigmos.Modules.ComputationalModules.Nullary;
|
|
|
|
public abstract partial class NormalDistributionModule : NullaryComputationalModule,
|
|
IParameterizedModule,
|
|
IDuplicateOutputModule
|
|
{
|
|
private HashSet<DataOutPort> OutputGroup { get; set; } = new();
|
|
private DataOutPort? Output1 { get; set; }
|
|
private DataOutPort? Output2 { get; set; }
|
|
private DataOutPort? Output3 { get; set; }
|
|
private DataOutPort? Output4 { get; set; }
|
|
private IDoubleParameter? Mu { get; set; }
|
|
private IDoubleParameter? Sigma { get; set; }
|
|
|
|
|
|
public override void Init()
|
|
{
|
|
base.Init();
|
|
this.DataOutInit("Output", 4);
|
|
this.SetOutputType(EnigmosConstant.DataPortTypes.Real);
|
|
Mu = GlobalProvider.DataStructureProvider!.NewDoubleParameter("mu", -1, 1, 0);
|
|
Sigma = GlobalProvider.DataStructureProvider.NewDoubleParameter("sigma", 0, 2, 1);
|
|
ConfigurableParameters = new HashSet<IConfigurableParameter> { Mu, Sigma };
|
|
PostInit();
|
|
}
|
|
|
|
public override void Define()
|
|
{
|
|
foreach (IDataOutPort op in DataOutPorts)
|
|
{
|
|
op.OutData.UpdateCalculation(x =>
|
|
(Normal.Get() * Sigma!.ParameterValue - Mu!.ParameterValue, EnigmosConstant.DataPortTypes.Real)
|
|
);
|
|
}
|
|
}
|
|
|
|
|
|
public HashSet<IConfigurableParameter> ConfigurableParameters { get; set; } = new();
|
|
} |