void _update_cursor() { DrawGaussian(m_ProbabilityFunc, Color.white); int x = (int)GetPosCursor().x; m_ProbabilityFunc = Bayesian.Adapt(m_ProbabilityFunc.m_Mu, m_ProbabilityFunc.m_Sigma, x, m_SpeedElastic, m_SpeedTransition); }
void _update_another_gaussian() { DrawSamples(m_Samples, Color.gray); DrawGaussian(m_ProbabilityFunc, Color.white); int x = (int)Bayesian.GetRandomXGaussinan(m_ProbabilityAnother.m_Mu, m_ProbabilityAnother.m_Sigma); m_ProbabilityFunc = Bayesian.Adapt(m_ProbabilityFunc.m_Mu, m_ProbabilityFunc.m_Sigma, x, m_SpeedElastic, m_SpeedTransition); DrawGaussian(m_ProbabilityAnother, Color.red); }
void TakeSamples(Bayesian.Gaussian g) { const int num = 10000; m_Samples = new float[m_Mat.width()]; for (int i = 0; i < num; ++i) { int x = (int)Bayesian.GetRandomXGaussinan(g.m_Mu, g.m_Sigma); if (x < 0 || x >= m_Mat.width()) { continue; } m_Samples[x] += 1f; } float max = m_Samples.Max(); for (int i = 0; i < m_Samples.Length; ++i) { m_Samples[i] /= max; } }
void DrawGaussian(Bayesian.Gaussian g, Color color) { float max_y = 0f; for (int x = 0; x < m_SizeImage.x; ++x) { float y = Bayesian.GetYGaussian(g.m_Mu, g.m_Sigma, x); if (y > max_y) { max_y = y; } } for (int x = 0; x < m_SizeImage.x; ++x) { float y = Bayesian.GetYGaussian(g.m_Mu, g.m_Sigma, x); y = m_SizeImage.y * y / max_y; double[] pixel = new double[4] { color.r *255, color.g *255, color.b *255, 255 }; m_Mat.put((int)y, x, pixel); } }