我要评分
获取效率
正确性
完整性
易理解

Uniform Distribution Function

Generate a random number vector that conforms to uniform distribution.

Interface Definition

KmlVslResult kml_vsl_runif(VslPolicy *policy, N01type normal_method, int len, double *dst, double min, double max)

Probability Density Function

Parameters

Parameter

Type

Description

Input/Output

len

int

Length of the input and output.

Input

min

double

Minimum value of the uniform distribution.

Input

max

double

Maximum value of the uniform distribution.

Input

dst

Pointer to data of the double type

Pointer to the result.

Output

Policy

Pointer to data of the VslPolicy type

Pointer to the random number generator structure.

Input

normal_method

N01type enumeration

Algorithm for generating normal distribution.

Input

Dependency

#include "kvsl.h"

Example

#include <stdio.h>
#include <time.h>
#include <stdlib.h>
#include "kvsl.h"
int main()
{
    VslPolicy *policy;
    kml_vsl_init(&policy, LECUYER_CMRG, time(NULL));
    int len = 10;
    double *dst = (double *)malloc(sizeof(double) * len);
    int a = kml_vsl_runif(policy, BOX_MULLER, len, dst, 0, 1);
    for (int i = 0; i < len; i++) {
        printf("%f ", dst[i]);
    }
    printf("\n");
    kml_vsl_destroy(policy);
}