Created
April 3, 2020 06:28
-
-
Save kaneta1992/ac4642095a755bc719d5e4b74c6e09cf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <cmath> | |
using namespace std; | |
float gauss(float sigma, float x) | |
{ | |
float sigma2 = sigma * sigma; | |
return exp(-(x * x) / (2.0f * sigma2)); | |
} | |
int main() | |
{ | |
float sum = 0.0f; | |
float weights[100]; | |
for (int i = 0; i < 11; i++) | |
{ | |
weights[i] = gauss(2.0f, (float)(i - 5)); | |
sum += weights[i]; | |
} | |
for (int i = 0; i < 11; i++) | |
{ | |
weights[i] /= sum; | |
cout << weights[i] << endl; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment