using Azure; using HTEX.Test.Service; using MathNet.Numerics; using System.Configuration; using System.Diagnostics; using System.Text.RegularExpressions; using TEAMModelOS.SDK.DI; using TEAMModelOS.SDK.Extension; namespace HTEX.Test { public class Program { public static void Main(string[] args) { Test(); var builder = WebApplication.CreateBuilder(args); // Add services to the container. builder.Services.AddControllers(); builder.Services.AddAzureStorage(builder.Configuration.GetValue("Azure:Storage:ConnectionString")); builder.Services.AddAzureRedis(builder.Configuration.GetValue("Azure:Redis:ConnectionString")); builder.Services.AddAzureCosmos(builder.Configuration.GetValue("Azure:Cosmos:ConnectionString")); builder.Services.AddAzureServiceBus(builder.Configuration.GetValue("Azure:ServiceBus:ConnectionString")); builder.Services.AddAzureSignalR(builder.Configuration.GetValue("Azure:SignalR:ConnectionString")); builder.Services.AddSnowflakeId(Convert.ToInt64(builder.Configuration.GetValue("Option:LocationNum")), 1); builder.Services.AddHttpClient(); var app = builder.Build(); // Configure the HTTP request pipeline. app.UseHttpsRedirection(); app.UseAuthorization(); app.MapControllers(); app.Run(); } public static string Test() { var a = new int[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27]; var b = new int[2192, 2379, 2070, 1813, 1662, 1421, 1134, 1043, 861, 763, 608, 563, 451, 358, 291, 252, 213, 170, 152, 133, 132, 95, 82, 71, 73, 63, 43]; // var per= GetPersent(array,3); // Console.WriteLine(per); //var data = MLService.GetNormalCluster(array.ToArray(),3,0.3); // var group = array.GroupBy(x=>x).Select(x=>new { key = x.Key, list = x.ToList()}).OrderBy(x=>x.key); // Console.WriteLine(group.Select(x => x.key).ToJsonString()); //Console.WriteLine(group.Select(x => x.list.Count()).ToJsonString()); //int count = 10; //int score = 10; //for (int i = 0; i < 10; i++) //{ // int work = Random.Shared.Next(1, count); // int right = Random.Shared.Next(1, work); // double xIRS = (work+right); // var exsIRS = 150/(1+Math.Exp(-(xIRS/2)))-75; // Console.WriteLine($"{i}=》答题 {work}-----{right}: {exsIRS}"); // double xPIC = (work+right*3); // var exsPIC = 40/(1+Math.Exp(-(xPIC/5)))-20; // Console.WriteLine($"{i}=》挑人 {work}-----{right}: {exsPIC}"); // double xBUS = (work+right*3+(work-right)); // var exsBUZ = 80/(1+Math.Exp(-(xBUS/3)))-40; // Console.WriteLine($"{i}=》抢权 {work}-----{right}: {exsBUZ}"); // int pscr = Random.Shared.Next(1, 10)*10; // int gscr = Random.Shared.Next(1, 10)*10; // double xSCR = (pscr + gscr ); // var exsSCR= 60/(1+Math.Exp(-(xSCR/8)))-30; // Console.WriteLine($"{i}=》计分 {pscr}-----{gscr}: {exsSCR}"); // double xWRK = (work); // var exsWRK = 150/(1+Math.Exp(-(xWRK)))-75; // Console.WriteLine($"{i}=》作品 {work}-----{right}: {exsBUZ}"); // int vt = Random.Shared.Next(1, 3); // int sc = Random.Shared.Next(1, 3); // int cm = Random.Shared.Next(1, 3); // int pt = Random.Shared.Next(1, 3); // double xCMT = (vt + sc+cm*2+pt); // var exsCMT = 100/(1+Math.Exp(-(xSCR/8)))-50; // Console.WriteLine($"{i}=》评分 {vt}-----{sc}---{cm}---{pt}: {exsCMT}"); // int b = Random.Shared.Next(1, 100)/20; // int m = Random.Shared.Next(1, 100)/20; // int g = Random.Shared.Next(1, 10)/2; // int t = Random.Shared.Next(1, 10)/2; // double xXZ = (b + m+g+t); // var exsXZ= 150/(1+Math.Exp(-(xSCR/8)))-75; // Console.WriteLine($"{i}=》协作 {b}-----{m}---{g}---{t}: {exsXZ}"); // var xALL = xXZ+xCMT+xWRK+xSCR+xBUS+exsPIC+xIRS; // var exsALL = 190/(1+Math.Exp(-(xALL/25)))-95; // Console.WriteLine($"{i}=》所有: {exsALL}"); //} //List nums = new List(); //for (int i = 0; i < 100; i++) //{ // nums.Add(Random.Shared.Next(1,5)); //} //for (int i = 0; i < 100; i++) //{ // nums.Add(Random.Shared.Next(4, 8)); //} //for (int i = 0; i < 100; i++) //{ // nums.Add(Random.Shared.Next(5, 20)); //} //for (int i = 0; i < 50; i++) //{ // nums.Add(Random.Shared.Next(15, 36)); //} //var per = GetPersent(nums, 11); //bool[] anomalies = MarkAnomalies(nums); //for (int i = 0; i < nums.Count; i++) //{ // if (anomalies[i]) { Console.WriteLine($"Number{ i}: {nums[i]} is an anomaly."); } //} return "Hello World!"; } static bool[] MarkAnomalies(List array) { if (array.Count == 0) return new bool[0]; double average = array.Average(); double variance = array.Average(x => Math.Pow(x - average, 2)); double standardDeviation = Math.Sqrt(variance); // 定义异常值的阈值,这里使用2倍标准差 double threshold =3* standardDeviation; bool[] anomalies = new bool[array.Count]; for (int i = 0; i < array.Count; i++) { double deviation = Math.Abs(array[i] - average); anomalies[i] = deviation > threshold; } return anomalies; } /// /// 计算当前元素在集合中超过了多少百分比的值 /// /// /// /// public static double GetPersent(IEnumerable nums, int curr) { int count = 0; foreach (var op in nums.OrderBy(x => x)) { if (op < curr) { count++; } else if (op == curr) { count++; } else { break; } } return count *1.0/ nums.Count() * 100; } public class KeyCount { public int count { get; set;} public int key { get; set;} } } }