A proper set of random number generators is implemented in the gnu gsl library.
You can pick from a quite variety of well tested random number generators. For serious computations, do not use rand().
In your case I would use a gsl_ran_sample from the given input set.
This would look like this:
#include <stdlib.h>
#include <gsl/gsl_rng.h>
#include <gsl/gsl_randist.h>
#define N 455
#define K 160
int main(int argc, char **argv)
{
double arr[N];
double randarr[K];
gsl_rng *r = NULL;
const gsl_rng_type *T;
int seed = 31456; // intial seed of the random number generator
int i;
// gsl_rng_env_setup(); // if you want to set different random number generators etc.. or set external seeds
T = gsl_rng_ranlxs2;
r = gsl_rng_alloc(T);
gsl_rng_set(r, seed);
for (i = 0; i < N; i++) {
arr[i] = i;
}
// gsl_ran_choose(r, randarr, K, arr, N, sizeof(double)); // without replacement
// in case of choose: you will need to call gsl_ran_shuffle(r, randarr, K, sizeof(double)) if you want to randomize the order.
gsl_ran_sample(r, randarr, K, arr, N, sizeof(double)); // with replacement
fprintf(stdout, "Picked array elements:\n");
for (i = 0; i < K; i++) {
fprintf(stdout, "%f\n", randarr[i]);
}
gsl_rng_free(r);
return 0;
}
if you have a properly installed gsl. compile with
gcc -Wall main.c `gsl-config --cflags --libs`