Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Logistics Predictor 5
using System; namespace Rextester { public class Program { private static Random rand = new Random(); public static void Main(string[] args) { calc(new float[]{0.5f, 0.55f, 0.6f, 0.625f, 0.6f, 0.55f, 0.5f, 0.45f, 0.4f, 0.375f, 0.4f, 0.45f}); } private static void calc(float[] target, float deviation = 100f, float final_deviation = 0.000001f, float speed = 0.9999f) { var target_count = (UInt16)target.Length; float guess = 2f, new_guess; float guess_deviation = logistics_score(guess, target), new_guess_deviation = 0f; param_report(guess, guess_deviation); logistics_report(guess, target_count); Console.WriteLine("\nStart\n"); while (deviation > final_deviation) { new_guess = guess + ((float)rand.NextDouble() - 0.5f) * deviation; new_guess = new_guess < 0 ? 0 : new_guess; new_guess_deviation = logistics_score(new_guess, target); if (new_guess_deviation < guess_deviation) { guess = new_guess; guess_deviation = new_guess_deviation; param_report(guess, guess_deviation); } deviation *= speed; } Console.WriteLine("\nDone\n"); param_report(guess, new_guess_deviation); logistics_report(guess, (UInt16)(target_count * 3)); } private static void param_report(float guess, float dist) { Console.WriteLine("param: " + guess + ", dist: " + dist); } private static float logistics_score(float param, float[] target) { float total_deviation = 0f, population = 0.6f; foreach (var f in target) { population = logistics(param, population); total_deviation += Math.Abs(f - population); } return total_deviation; } private static void logistics_report(float param, UInt16 length) { float population = 0.6f; for (byte n = 0; n < length; n++) { population = logistics(param, population); Console.Write(population + " "); } Console.WriteLine(); } private static float logistics(float param, float population) { return param * population * (1f - population); } } }
run
|
edit
|
history
|
help
0
іфи
JagArray
1.1 Basics: language constructs
s
dfg reter ter ertert
count occurances
Work Days
code
sdfrgthyjuytrfdf
Rextester