Skip to content
This repository has been archived by the owner on May 11, 2023. It is now read-only.

Commit

Permalink
New random distributions and small enhancements
Browse files Browse the repository at this point in the history
  • Loading branch information
okozelsk committed Sep 7, 2019
1 parent c60dfa5 commit 286d03b
Show file tree
Hide file tree
Showing 23 changed files with 1,348 additions and 600 deletions.
240 changes: 211 additions & 29 deletions Demo/DemoConsoleApp/DemoSettings.xml

Large diffs are not rendered by default.

60 changes: 42 additions & 18 deletions Demo/DemoConsoleApp/Research.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,56 @@ namespace RCNet.DemoConsoleApp
class Research
{
//Attributes
private Random _rand;

//Constructor
public Research()
{
_rand = new Random();
return;
}

//Methods
public void Run()
{
BasicStat sampleStat = new BasicStat();

//Pulse generator test
sampleStat.Reset();
PulseGeneratorSettings modSettings = new PulseGeneratorSettings(1, 1.5, PulseGeneratorSettings.TimingMode.Poisson);
IGenerator generator = new PulseGenerator(modSettings);

int steps = 10000;
double period = 0;
for (int i = 0; i < steps; i++)
{
++period;
double sample = generator.Next();
//Console.WriteLine(sample);
if(sample != 0)
{
sampleStat.AddSampleValue(period);
period = 0;
}
}
Console.WriteLine($"Mean: {sampleStat.ArithAvg} StdDev: {sampleStat.StdDev} Min: {sampleStat.Min} Max: {sampleStat.Max}");
Console.ReadLine();



//Random distributions test
BasicStat rStat = new BasicStat();
for(int i = 0; i < 200; i++)
{
double r = _rand.NextFilterredGaussianDouble(0.5, 1, -0.5, 1);
rStat.AddSampleValue(r);
Console.WriteLine(r);
}
Console.WriteLine($"Mean: {rStat.ArithAvg} StdDev: {rStat.StdDev} Min: {rStat.Min} Max: {rStat.Max}");
Console.ReadLine();



//Activation tests
double fadingSum = 0;
for(int i = 0; i < 1000; i++)
Expand Down Expand Up @@ -144,22 +184,6 @@ public void Run()



//TimeSeriesGenerator.SaveTimeSeriesToCsvFile("MackeyGlass_big.csv", "Value", TimeSeriesGenerator.GenMackeyGlassTimeSeries(16000), CultureInfo.InvariantCulture);
MackeyGlassGeneratorSettings modSettings = new MackeyGlassGeneratorSettings(18, 0.1, 0.2);
IGenerator generator = new MackeyGlassGenerator(modSettings);

int steps = 100;
for (int i = 0; i < steps; i++)
{
Console.WriteLine(generator.Next());
}
Console.ReadLine();
generator.Reset();
for (int i = 0; i < steps; i++)
{
Console.WriteLine(generator.Next());
}
Console.ReadLine();

///*
SimpleIFSettings settings = new SimpleIFSettings(new RandomValueSettings(15, 15),
Expand All @@ -179,10 +203,10 @@ private void TestActivation(IActivationFunction af, int simLength, double constC
Random rand = new Random();
for (int i = 1; i <= simLength; i++)
{
double signal = 0;
double signal;
if (i >= from && i < from + count)
{
double input = double.IsNaN(constCurrent) ? rand.NextDouble(0, 1, false, RandomClassExtensions.DistributionType.Uniform) : constCurrent;
double input = double.IsNaN(constCurrent) ? rand.NextDouble() : constCurrent;
signal = af.Compute(input);
}
else
Expand Down
2 changes: 1 addition & 1 deletion Demo/DemoConsoleApp/TimeSeriesGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public static List<double> GenTimeSeries(IGenerator generator, int length)
/// <returns>A collection of random values</returns>
public static List<double> GenRandomTimeSeries(int length, int seek = -1)
{
RandomValueSettings settings = new RandomValueSettings(0, 1, false, Extensions.RandomClassExtensions.DistributionType.Uniform);
RandomValueSettings settings = new RandomValueSettings(0, 1, false);
RandomGenerator generator = new RandomGenerator(settings, seek);
return GenTimeSeries(generator, length);
}
Expand Down
Binary file added RCNet/Docs/Imgs/Components.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace RCNet.Extensions
/// <summary>
/// Useful extensions of Array class
/// </summary>
public static class ArrayClassExtensions
public static class ArrayExtensions
{
/// <summary>
/// Shifts all array elements to the right and sets the first element value to newValue
Expand Down Expand Up @@ -189,7 +189,7 @@ public static void ShuffledIndices(this int[] array, Random rand)
return;
}

}//ArrayClassExtensions
}//ArrayExtensions

}//Namespace

Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace RCNet.Extensions
/// <summary>
/// Useful extensions of Double class.
/// </summary>
public static class DoubleClassExtensions
public static class DoubleExtensions
{
/// <summary>
/// Checks if this is computable double value.
Expand Down Expand Up @@ -64,6 +64,6 @@ public static double Power(this double x, uint exponent)
}
}

}//DoubleClassExtensions
}//DoubleExtensions

}//Namespace
127 changes: 0 additions & 127 deletions RCNet/Extensions/RNGCryptoServiceProviderClassExtension.cs

This file was deleted.

Loading

0 comments on commit 286d03b

Please sign in to comment.