私の指示:正規分布の平均uと標準偏差sをユーザーに尋ねるプログラムを作成します(wikiの記事を参照) 。
次に、プログラムはNを要求し、次にN値xを要求します。xごとf(x)
に、画面に書き込みます。プログラムはユーザーにu、s、およびNを1回だけ要求することに注意してください。その後、xのN個の値を1つずつ要求します。各値xの後に、関数の対応する値を書き出します。
私が混乱しているのは、Nが何を表すのかということです。xの数だと思いましたが、誰かが私のためにこれを明確にすることができますか?
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <stdlib.h>
int main()
{
double u,s, N, x1,math1, math2, math3,n, v, x;
printf("Enter Mean: ");
scanf("%lf", &u);
printf("Enter Standard Deviation: ");
scanf("%lf", &s);
printf("Enter number of x's: ");
scanf("%lf", &N);
for (v=1; v<=N; v++)
{
printf("Enter Value: ");
scanf("%lf", &x);
n=(-1/2);
printf("f(x)= ");
math1 =1/(u*sqrt(2*M_PI));
math2= (x-u)/s * (x-u)/s;
math3= M_E * exp(n);
x1 = math1 * exp(math3)*exp(math2);
printf("%lf \n", x1);
}
system("Pause");
}