Keyword: 累積正規分布関数
概要
本サンプルは累積正規分布関数を求めるC言語によるサンプルプログラムです。 本サンプルは引数xを読み込み、xの各値について以下に示される累積正規分布関数を求めて出力します。
※本サンプルはnAG Cライブラリに含まれる関数 nag_cumul_normal() のExampleコードです。本サンプル及び関数の詳細情報は nag_cumul_normal のマニュアルページをご参照ください。
ご相談やお問い合わせはこちらまで
入力データ
(本関数の詳細はnag_cumul_normal のマニュアルページを参照)1 2 3 4 5 6 7
このデータをダウンロード |
nag_cumul_normal (s15abc) Example Program Data -20.0 -1.0 0.0 1.0 2.0 20.0
- 1行目はタイトル行で読み飛ばされます。
- 2~7行目に累積正規分布関数の引数xの値を指定しています。
出力結果
(本関数の詳細はnag_cumul_normal のマニュアルページを参照)1 2 3 4 5 6 7 8
この出力例をダウンロード |
nag_cumul_normal (s15abc) Example Program Results x y -2.000e+01 2.754e-89 -1.000e+00 1.587e-01 0.000e+00 5.000e-01 1.000e+00 8.413e-01 2.000e+00 9.772e-01 2.000e+01 1.000e+00
- 3~8行目に引数xの値と累積正規分布関数の値が出力されています。
ソースコード
(本関数の詳細はnag_cumul_normal のマニュアルページを参照)
※本サンプルソースコードはnAG数値計算ライブラリ(Windows, Linux, MAC等に対応)の関数を呼び出します。
サンプルのコンパイル及び実行方法
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 28 29 30 31 32 33 34
このソースコードをダウンロード |
/* nag_cumul_normal (s15abc) Example Program. * * CLL6I261D/CLL6I261DL Version. * * Copyright 2017 Numerical Algorithms Group. * * Mark 26.1, 2017. */ #include <nag.h> #include <stdio.h> #include <nag_stdlib.h> #include <nags.h> int main(void) { Integer exit_status = 0; double x, y; /* Skip heading in data file */ scanf("%*[^\n]"); printf("nag_cumul_normal (s15abc) Example Program Results\n"); printf(" x y\n"); while (scanf("%lf", &x) != EOF) { /* nag_cumul_normal (s15abc). * Cumulative Normal distribution function P(x) */ y = nag_cumul_normal(x); printf("%12.3e%12.3e\n", x, y); } return exit_status; }