<jupyter_start><jupyter_text>Notebook to test out NAG Python Library Generate a random correlation matrix (g05py)<jupyter_code>import numpy as np
import naginterfaces.library.rand as nirand
n=10
np.random.seed(54321)
d = np.random.rand(n)
c = np.zeros((n,n))
#ensure the sum of d is the same as the number of elements
d = d*n/d.sum()
d.sum()
seed = [1]
statecomm = nirand.init_repeat(1,seed)
c = nirand.matrix_corr(d,statecomm)
print (np.matrix(c))<jupyter_output>[[ 1.          0.12564145 -0.00764626 -0.16539236 -0.0057206   0.33249834
  -0.30321203 -0.21418952  0.00680034 -0.05270024]
 [ 0.12564145  1.         -0.22944284 -0.30689584  0.01636082  0.15489516
   0.09513636 -0.11511604  0.02053952 -0.02445098]
 [-0.00764626 -0.22944284  1.         -0.05145711 -0.0028276  -0.22348789
   0.11902808  0.22075883 -0.07590371  0.1018837 ]
 [-0.16539236 -0.30689584 -0.05145711  1.          0.10975949  0.16784829
   0.29459949 -0.03324149 -0.16856802  0.28284157]
 [-0.0057206   0.01636082 -0.0028276   0.10975949  1.          0.45541538
  -0.00205822 -0.18870226  0.07874764  0.0127316 ]
 [ 0.33249834  0.15489516 -0.22348789  0.16784829  0.45541538  1.
   0.00766639  0.20634005 -0.02867739 -0.09530013]
 [-0.30321203  0.09513636  0.11902808  0.29459949 -0.00205822  0.00766639
   1.         -0.15300155  0.20595416 -0.32157421]
 [-0.21418952 -0.11511604  0.22075883 -0.03324149 -0.18870226  0.20634005
  -0.15300155  1.          0.10960632  0.23585012]
 [ 0.006[...]<jupyter_text>Try the same thing but with pandas dataframes<jupyter_code>import pandas as pd
n=10
df = pd.DataFrame(np.random.rand(n))
df.head()
df = df*n/df.sum()
df.sum()
df[0]
seed_pd = [1]
statecomm_pd = nirand.init_repeat(1,seed_pd)
c_df = pd.DataFrame(np.random.rand(n,n))
c_df.head()
c_df = nirand.matrix_corr(df[0],statecomm_pd)
c_df
gdf = pd.DataFrame(c_df)
gdf.head()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.14019189765458423, 'fraction_numerical': 0.35767590618336886, 'mean_word_length': 3.143487858719647, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '320751', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 1233, 'n_tokens_neox': 880, 'n_words': 162, 'path': 'random_number_generation/rand_corr_mat.ipynb', 'repo_name': 'Brunochris13/NAGPythonExamples', 'size': '1876'}