Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some typos in the execution sample code #8

Open
Y-Saki26 opened this issue Aug 4, 2023 · 0 comments · May be fixed by #9
Open

Some typos in the execution sample code #8

Y-Saki26 opened this issue Aug 4, 2023 · 0 comments · May be fixed by #9

Comments

@Y-Saki26
Copy link

Y-Saki26 commented Aug 4, 2023

There are some parts that do not work due to typos or name errors when the module is executed as a script.

ch3_metrics.py: from l38

- def mutualInfor(x,y, norm=False):
+ def mutualInfo(x,y, norm=False):
    #mutual information
    bXY = numBins(x.shape[0], corr = np.corrcoef(x,y)[0,1])
    cXY = np.histogram2d(x,y, bXY)[0]
    iXY = mutual_info_score(None, None, contingency=cXY)
    if norm:
-        hX = ss.entropy(np.histogram(x, bins)[0]) #marginal 
-        hY = ss.entropy(np.histogram(y, bins)[0]) #marginal
+        hX = ss.entropy(np.histogram(x, bXY)[0]) #marginal 
+        hY = ss.entropy(np.histogram(y, bXY)[0]) #marginal
        iXY /= min(hX, hY) #normalized mutual information

ch7_portfolio_construction.py: from l120

    # code snippet 7.4 - intracluster optimal allocations
    # step 2. compute intracluster allocations using the denoised cov matrix
    wIntra = pd.DataFrame(0, index=cov0.index, columns=clstrs.keys())
    for i in clstrs:
-        wIntra.loc[clstrs[i], i] = minVarPort(cov1.loc[clstrs[i], clstrs[i]]).flatten()
+        wIntra.loc[clstrs[i], i] = minVarPort(corr1.loc[clstrs[i], clstrs[i]]).flatten()
@Y-Saki26 Y-Saki26 linked a pull request Aug 4, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant