Skip to content

Making cross-sectional statistics and scalar outputs #319

Closed Answered by AdamGlustein
poldpold asked this question in Q&A
Discussion options

You must be logged in to vote

Here is the corrected version of the code with comments as to the changes.

import numpy as np
import csp
from datetime import timedelta, datetime
from csp.random import brownian_motion

number_of_products = 10

@csp.graph
def graph():
    trigger = csp.timer(timedelta(minutes=1), 1)
    prices = [csp.random.brownian_motion_1d(trigger=trigger, drift=csp.const(0.0), variance=csp.const(1.0/60**.5), seed=p) for p in range(number_of_products)]
    prices = csp.stats.list_to_numpy(prices)
    
    # Use csp.apply to "apply" the np.max/np.min functions to each individual value in "prices"
    # Note that np.min and np.max cannot be called directly since 'prices' is an Edge here
    # We want to …

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by AdamGlustein
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants