noisymoon API
Unit root-tests and reaction–diffusion simulation over HTTP
This API lets you call the computations covered in this site’s articles from your own programs.
- Tests: ADF and KPSS tests (matching statsmodels), t-tests (one-sample, two-sample and paired; one- or two-sided; matching scipy), the Shapiro–Wilk normality test (matching R and scipy), and rank tests (Mann–Whitney, Wilcoxon signed-rank and Kruskal–Wallis; matching scipy).
- State space models: Kalman filtering and smoothing (you specify the matrices; missing values are supported), maximum likelihood estimation of the local level model (matching statsmodels), and a sequential filter that advances one period per observation (gRPC bidirectional stream).
- Information: Kullback–Leibler divergence, Fisher information (Cramér–Rao lower bound and standard errors), and distribution fitting with comparison by AIC and BIC.
- Multivariate analysis: principal component analysis (eigenvalues, explained variance ratios, loadings, scores and parallel analysis; matching scikit-learn).
- Regression-field tests: a test for imitation in covariate space (panel data, split-sample IV; matching the paper’s reference implementation).
- Simulation: the Gray-Scott reaction–diffusion system. Results are returned as an image (PNG) and a NumPy array (
.npy).
Create an account / issue an API key →
Pricing
Billing uses prepaid credits. Only what you use is deducted from your balance.
| Item | Price |
|---|---|
| ADF / KPSS / t-test / Shapiro–Wilk / Mann–Whitney / Wilcoxon / Kruskal–Wallis / Kalman filter / local level / information / PCA / SEM / growth curves | ¥1 per call |
| Sequential Kalman filter (gRPC) | ¥0.01 per observed period |
| Imitation test | ¥1 per million unit × time cells (minimum ¥1; about ¥3.1 for 100,000 units × 31 times) |
| Gray-Scott | ¥0.01 per million cell-steps (about ¥6.6 for a 256×256 grid and 10,000 steps) |
| Purchase units | ¥500 / ¥1,000 / ¥5,000 (tax included; credit card) |
- Credits expire 180 days after purchase.
- You are not charged when a computation fails, for example because of invalid input. If a simulation fails, its cost is refunded.
- The “Try it” demos in the articles are free (up to 500 points per series and up to 10 calls per minute).
Usage
1. Issue an API key
Log in with your email address on the Account page, purchase credits and issue a key. Keys are strings starting with nm_ and are shown only once, when they are issued.
2. Call the API
Send the key in the X-API-Key header.
curl -X POST "https://api.noisymoon.jp/v1/tests/adf?lang=en" \
-H "X-API-Key: $NOISYMOON_KEY" \
-d '{"series": [0.12, 0.35, 0.10, 0.44, 0.61, 0.52, 0.80, 0.77, 0.95, 1.10], "regression": "c"}'From Python:
import os, requests
API = "https://api.noisymoon.jp"
H = {"X-API-Key": os.environ["NOISYMOON_KEY"]}
r = requests.post(f"{API}/v1/tests/adf", headers=H, params={"lang": "en"},
json={"series": list(y), "regression": "ct", "autolag": "AIC"})
r.raise_for_status()
res = r.json()
print(res["statistic"], res["pvalue"], res["critical_values"])Simulations take time, so they are accepted as “jobs”; you fetch the results once they have finished.
import io, time, numpy as np
job = requests.post(f"{API}/v1/sim/gray-scott", headers=H,
json={"n": 256, "steps": 10000, "F": 0.0367, "k": 0.0649, "init": "random"}).json()
while True:
st = requests.get(f"{API}/v1/jobs/{job['id']}", headers=H).json()
if st["status"] in ("done", "failed"):
break
time.sleep(2)
v = np.load(io.BytesIO(requests.get(f"{API}/v1/jobs/{job['id']}/v.npy", headers=H).content))3. Response language
By default, error messages and descriptive fields in responses (such as null_hypothesis) are in Japanese. To receive them in English, add the query parameter ?lang=en or send the header Accept-Language: en. If both are present, lang takes precedence. Only the text values change; JSON keys and numbers are the same in either language. Every response carries a Content-Language header (en or ja) indicating the language used.
To use English for every call without adding the parameter each time, set it once on a requests.Session:
s = requests.Session()
s.headers["X-API-Key"] = os.environ["NOISYMOON_KEY"]
s.params = {"lang": "en"}
s.post(f"{API}/v1/tests/shapiro", json={"x": list(a)}).json()The remaining examples on this page omit lang for brevity.
Tools at a glance
For each tool, the table summarizes the data it needs, its assumptions and the values it returns. Detailed explanations and proofs are in the corresponding articles.
| Tool | Required data | Assumptions | Output |
|---|---|---|---|
| ADF test (Japanese) | A single time series (at least 10 points) and the choice of deterministic terms | The null hypothesis is a unit root. Low power; sensitive to structural breaks | Statistic, p-value, selected lag, critical values |
| KPSS test | A single time series; level stationarity or trend stationarity | The null hypothesis is stationarity. Use together with ADF | Statistic, p-value (with a note if outside the table’s range), lag, critical values |
| t-test (Japanese) | Sample x (and y), the null value, one- or two-sided | Normality and independence. Two-sample tests assume equal variances by default (Welch is also available) | t, degrees of freedom, p-value, estimate and standard error, confidence interval |
| Shapiro–Wilk test | A single sample (3–5,000 points) | i.i.d. from a continuous distribution. With large samples, even small departures lead to rejection | W, p-value, sample size, mean and standard deviation |
| Mann–Whitney, Wilcoxon, Kruskal–Wallis | Two samples x, y / one sample or paired x, y / k groups (up to 100,000 points each) | Independence. The null hypothesis is “the distributions are the same” (for Wilcoxon, “symmetric about 0”); these are not-tests of the median. The significance level breaks down when comparing groups with different variances | Statistic, p-value, method used (exact distribution / normal approximation / permutation), effect sizes, Hodges–Lehmann estimate, mean rank for each group |
| Kalman filter (Japanese) | A sequence of observations (missing values allowed), matrices F, H, Q, R, initial values (optional) | Linear and Gaussian; time-invariant matrices | Means and covariances of predictions, filtered and smoothed states; prediction errors; log-likelihood; one-step-ahead forecast |
| Local level (Japanese) | A single time series (at least 3 points; missing values allowed) | A random-walk level plus independent observation noise | Estimates of the two variances, filtered and smoothed level with standard deviations, AIC, one-step-ahead forecast |
| KL divergence (Japanese) | A distribution family and the parameters of two distributions (probability vectors for discrete) | Same family; parameters within their valid ranges | KL(P‖Q), KL(Q‖P), Jeffreys divergence, values in bits |
| Fisher information (Japanese) | A distribution family and either parameter values plus n, or a sample | Regularity conditions; the family is correctly specified | Information matrix, Cramér–Rao lower bound, MLEs and standard errors |
| Distribution fitting (Japanese) | A single sample (at least 3 points) | i.i.d.; continuous and discrete values are not mixed | Per-distribution MLEs, likelihood, AIC, BIC, Akaike weights; the best distribution |
| PCA (Japanese) | A data matrix (2–50 variables; missing values allowed), or a covariance/correlation matrix plus n | Linear relationships; use the correlation matrix if units differ; sensitive to outliers | Eigenvalues, explained variance ratios, eigenvectors, loadings, scores; number of components by the Kaiser criterion and parallel analysis |
| SEM (Japanese) | A model in lavaan syntax, and a data matrix (missing values allowed) or a covariance matrix plus n (plus means for a mean structure) | Multivariate normality (maximum likelihood); the model must be identified; listwise deletion of missing values | Estimates, standard errors, z, p-values, 95% intervals, standardized solution, R², χ² test, CFI, TLI, RMSEA (90% interval), SRMR, AIC, BIC, residual covariances |
| Latent growth curves (Japanese) | One column per time point (3–20 time points; missing values allowed), the time values, the shape (linear, quadratic, latent basis) and time-invariant covariates (optional) | Multivariate normality (maximum likelihood); everyone is measured at the same time points; listwise deletion of missing values | Means, variances and covariances of the growth factors; mean trajectory; shape comparison (χ² difference tests, AIC, BIC); individual factor scores; the same fit indices as SEM |
| Imitation test | A panel following the same units at equally spaced times: a 1-D covariate x and a 0/1 outcome y (at least 100 units and 4 times, no missing values) | Covariates follow an OU process around their mean (or do not move); outcomes change by a bistable reaction plus imitation of nearby units; the approximation needs the imitation window to be narrower than the scale of the field. Not identified on a travelling front | Σ_I (diffusion due to imitation), bootstrap standard error, z, one-sided p-value; θ and Σ of the covariates; r and a of the reaction |
| Gray-Scott | Grid size, number of steps, coefficients such as F and k | Stability condition of the explicit Euler method, dt·max(Du,Dv) ≤ 0.25 | Image (PNG) and array (.npy) of the v field, summary statistics |
Endpoints
| Method | Path | Description |
|---|---|---|
| POST | /v1/tests/adf |
ADF test |
| POST | /v1/tests/kpss |
KPSS test |
| POST | /v1/tests/ttest-1samp |
One-sample t-test |
| POST | /v1/tests/ttest-2samp |
Two-sample t-test (equal variances / Welch) |
| POST | /v1/tests/ttest-paired |
Paired two-sample t-test |
| POST | /v1/tests/shapiro |
Shapiro–Wilk normality test |
| POST | /v1/tests/mannwhitney |
Mann–Whitney U test |
| POST | /v1/tests/wilcoxon |
Wilcoxon signed-rank test (one-sample, paired) |
| POST | /v1/tests/kruskal |
Kruskal–Wallis test |
| POST | /v1/statespace/kalman |
Kalman filter, smoother and likelihood |
| POST | /v1/statespace/local-level |
Maximum likelihood estimation of the local level model and level smoothing |
| gRPC | grpc.noisymoon.jp:443 KalmanFilter/Filter |
Sequential Kalman filter (bidirectional stream) |
| POST | /v1/info/kl |
KL divergence |
| POST | /v1/info/fisher |
Fisher information |
| POST | /v1/info/select-distribution |
Distribution fitting with AIC and BIC |
| POST | /v1/multivariate/pca |
Principal component analysis |
| POST | /v1/sem/fit |
Maximum likelihood estimation of structural equation models (SEM, CFA, latent growth curves) |
| POST | /v1/sem/growth |
Latent growth curves (automatic syntax generation, shape comparison, factor scores) |
| POST | /v1/tests/imitation |
Submit an imitation-test job (returns 202) |
| POST | /v1/sim/gray-scott |
Submit a Gray-Scott job (returns 202) |
| GET | /v1/jobs/{id} |
Job status and result summary |
| GET | /v1/jobs/{id}/v.png |
Result image (v field, viridis) |
| GET | /v1/jobs/{id}/v.npy |
Result array (float32, shape (n, n)) |
| GET | /v1/usage |
Usage over the last 30 days and current balance |
| GET | /v1/pricing |
Current prices (no key required) |
ADF test POST /v1/tests/adf
| Parameter | Default | Description |
|---|---|---|
series |
(required) | Array of numbers, 10–100,000 points |
regression |
"c" |
Deterministic terms: "n" (none) / "c" (constant) / "ct" (constant + trend) / "ctt" (+ quadratic trend) |
autolag |
"AIC" |
Lag selection: "AIC" / "BIC" / "t-stat" / null (use maxlag as is) |
maxlag |
\(12(n/100)^{1/4}\) | Maximum lag |
The procedure and defaults are the same as statsmodels’ adfuller. For how the test works, see the ADF test article (Japanese).
KPSS test POST /v1/tests/kpss
| Parameter | Default | Description |
|---|---|---|
series |
(required) | Array of numbers |
regression |
"c" |
"c" (level stationary) / "ct" (trend stationary) |
nlags |
"auto" |
"auto" (Hobijn et al. 1998) / "legacy" / integer |
t-tests POST /v1/tests/ttest-1samp · ttest-2samp · ttest-paired
| Parameter | Default | Description |
|---|---|---|
x |
(required) | Array of numbers (2–100,000 points) |
y |
(required for two-sample and paired) | Array of numbers. For paired tests, the same length as x |
mu0 |
0 |
Null value (the mean for one-sample; the mean of the difference x − y for two-sample and paired) |
alternative |
"two-sided" |
"two-sided" / "greater" / "less" |
equal_var |
true |
Two-sample only. true assumes equal variances (Student; UMP unbiased), false uses Welch |
confidence |
0.95 |
Confidence level of the interval |
The response contains statistic (t), df, pvalue, estimate (the mean or the difference), stderr and confidence_interval (for one-sided tests, one end is null, meaning infinity). The definitions are the same as scipy’s ttest_1samp / ttest_ind / ttest_rel. For the theory, see the t-test article (Japanese).
r = requests.post(f"{API}/v1/tests/ttest-2samp", headers=H,
json={"x": list(a), "y": list(b), "alternative": "greater"}).json()
print(r["statistic"], r["df"], r["pvalue"], r["confidence_interval"])Shapiro–Wilk test POST /v1/tests/shapiro
| Parameter | Default | Description |
|---|---|---|
x |
(required) | Array of numbers (3–5,000 points) |
The response contains statistic (W), pvalue, n, mean and sd. The null hypothesis is “the sample comes from a normal distribution”; the smaller W, the smaller the p-value. The coefficients and p-value use Royston’s (1995) approximation (AS R94) and match R’s shapiro.test and scipy’s shapiro. For n = 3 the exact distribution is used. For the theory, see the Shapiro–Wilk test article.
r = requests.post(f"{API}/v1/tests/shapiro", headers=H, json={"x": list(a)}).json()
print(r["statistic"], r["pvalue"])Rank tests POST /v1/tests/mannwhitney, wilcoxon, kruskal
| Parameter | Default | Description |
|---|---|---|
x, y |
(both required for Mann–Whitney; x required for Wilcoxon) |
Arrays of numbers (1–100,000 points each). For Wilcoxon, passing y tests the differences x − y |
groups |
(required for Kruskal–Wallis) | Array of arrays of numbers (2–100 groups, up to 100,000 points in total). Name the groups with labels |
alternative |
"two-sided" |
"two-sided" / "greater" / "less" (Mann–Whitney and Wilcoxon) |
method |
"auto" |
"auto" / "exact" / "asymptotic". auto chooses by the same rule as scipy |
use_continuity |
true |
Continuity correction for the Mann–Whitney normal approximation |
correction |
false |
Continuity correction for the Wilcoxon normal approximation |
zero_method |
"wilcox" |
Handling of zero differences in Wilcoxon: "wilcox" / "pratt" / "zsplit" |
The response contains statistic, pvalue, method (exact / asymptotic / permutation), effect sizes (prob_superiority, rank_biserial, epsilon_squared) and hodges_lehmann. The statistics and p-values match scipy’s mannwhitneyu / wilcoxon / kruskal. For the theory, see the rank tests article.
r = requests.post(f"{API}/v1/tests/kruskal", headers=H,
json={"groups": [list(a), list(b), list(c)], "labels": ["A", "B", "C"]}).json()
print(r["statistic"], r["pvalue"], [g["mean_rank"] for g in r["groups"]])Kalman filter POST /v1/statespace/kalman
| Parameter | Default | Description |
|---|---|---|
y |
(required) | Array of length T. In one dimension, each element is a number or null; in p dimensions, each time point is an array of length p (individual components may be null) |
F, H, Q, R |
(required) | State transition m×m, observation p×m, state noise covariance m×m, observation noise covariance p×p. A 1×1 matrix may be given as a number |
x0, P0 |
Approximate diffuse initialization | Mean (length m) and covariance (m×m) of the initial state. If both are omitted, P0 = 10⁶ I and the first m periods are excluded from the likelihood |
smooth |
true |
Also compute the smoothed states |
return_cov |
true |
Also return the covariance matrix for each period (set to false when T×m² exceeds 2 million) |
Limits: T ≤ 100,000; m, p ≤ 20. The results match statsmodels’ state space models (relative error 10⁻⁸ with known initial values).
Local level model POST /v1/statespace/local-level
Send just {"y": [...]} (missing values as null) and the API estimates the two variances — observation noise and changes in the level — by maximum likelihood, and returns the filtered and smoothed level with standard deviations, AIC and a one-step-ahead forecast.
r = requests.post(f"{API}/v1/statespace/local-level", headers=H, json={"y": list(y)}).json()
r["params"], r["level"]["smoothed"]Sequential Kalman filter (gRPC) grpc.noisymoon.jp:443
A bidirectional-streaming gRPC service that advances the filter by one period each time an observation arrives. Keep the connection open and send observations one at a time; each one returns the filtered state, the next-period forecast and the log-likelihood (for real-time sensor or market data). Each step is the same computation as POST /v1/statespace/kalman above: streaming the same series gives bit-for-bit identical filtered values.
| Item | Details |
|---|---|
| Service | noisymoon.statespace.v1.KalmanFilter/Filter (kalman.proto) |
| Flow | First send a Model (F, H, Q, R, optionally x0 and P0) → Ready. Then each Observation (length p, NaN for missing) → State |
| Returns | filtered_mean, forecast_mean (next-period prediction), innovation, loglik_obs and cumulative loglik; covariances too with return_cov: true |
| Auth | Metadata x-api-key. Send accept-language: en for English error messages |
| Price | ¥0.01 per observed period (deducted in batches of 100 periods and when the stream ends) |
| Limits | State and observation dimensions up to 20; up to 5 concurrent streams per key |
pip install grpcio grpcio-tools
mkdir -p noisymoon/statespace/v1
curl -o noisymoon/statespace/v1/kalman.proto https://noisymoon.jp/api/kalman.proto
python -m grpc_tools.protoc -I. --python_out=. --grpc_python_out=. noisymoon/statespace/v1/kalman.protoimport os, queue
import grpc
from noisymoon.statespace.v1 import kalman_pb2 as pb, kalman_pb2_grpc as pbg
def M(rows): # matrix (row-major)
return pb.Matrix(rows=len(rows), cols=len(rows[0]), data=[v for r in rows for v in r])
channel = grpc.secure_channel("grpc.noisymoon.jp:443", grpc.ssl_channel_credentials())
stub = pbg.KalmanFilterStub(channel)
q = queue.Queue() # each observation put here is sent to the server right away
def requests():
# local level model: μ_{t+1} = μ_t + η_t, y_t = μ_t + ε_t
yield pb.FilterRequest(model=pb.Model(F=M([[1.0]]), H=M([[1.0]]), Q=M([[0.1]]), R=M([[1.0]])))
while (y := q.get()) is not None:
yield pb.FilterRequest(observation=pb.Observation(y=[y]))
responses = stub.Filter(requests(), metadata=[("x-api-key", os.environ["NOISYMOON_KEY"]), ("accept-language", "en")])
print(next(responses).ready) # dimensions, price, balance
for y in [1.2, 0.9, float("nan"), 1.5]: # NaN = missing
q.put(y)
s = next(responses).state
print(s.t, round(s.filtered_mean[0], 4), round(s.forecast_mean[0], 4), round(s.loglik, 4))
q.put(None) # finish sending
for _ in responses: # read until the server closes the stream (final billing happens here)
pass
channel.close()When your balance runs out, the stream ends with RESOURCE_EXHAUSTED. Invalid input gives INVALID_ARGUMENT; a bad key gives UNAUTHENTICATED.
Information POST /v1/info/kl · fisher · select-distribution
requests.post(f"{API}/v1/info/kl", headers=H, json={
"family": "gamma", "p": {"shape": 2, "rate": 1}, "q": {"shape": 3, "rate": 1.5}}).json()
requests.post(f"{API}/v1/info/fisher", headers=H, json={"family": "normal", "params": {"mu": 0, "sigma2": 4}, "n": 50}).json()
requests.post(f"{API}/v1/info/fisher", headers=H, json={"family": "gamma", "sample": list(x)}).json() # MLEs and standard errors
requests.post(f"{API}/v1/info/select-distribution", headers=H, json={"x": list(x)}).json()KL families and parameters: normal (mu, sigma), mvnormal (mean, cov), exponential (rate), poisson (lambda), gamma (shape, rate), discrete (p and q as probability vectors). Fisher families and parameters: normal (mu, sigma2), poisson (lambda), binomial (p; trials required), exponential (rate), gamma (shape, rate). Candidates for distribution fitting are normal, lognormal, exponential, gamma and weibull for continuous data, and poisson and negbinom for discrete data (plus binomial if you pass trials). If every value in the sample is a non-negative integer, the discrete candidates are used.
Principal component analysis POST /v1/multivariate/pca
| Parameter | Default | Description |
|---|---|---|
X |
Either this or cov |
Data matrix (rows are observations, columns are variables; missing values as null, and such rows are dropped) |
cov, n |
Either this or X |
Covariance or correlation matrix and the sample size (without n, parallel analysis is skipped) |
names |
x1, x2, … |
Variable names |
scale |
true |
true uses the correlation matrix (standardized, dividing by n−1); false uses the covariance matrix |
n_components |
All | Number of components to return |
parallel_reps, seed |
100, 0 |
Number of parallel-analysis replications (0 to skip) and the random seed |
return_scores |
true |
Return principal component scores |
Structural equation modeling POST /v1/sem/fit
| Parameter | Default | Description |
|---|---|---|
model |
Required | lavaan syntax (=~ measurement, ~ regression, ~~ variances and covariances, ~ 1 intercepts; modifiers: a number = fixed, NA = free, a name = equality constraint, start(x)). Statements are separated by newlines or ; |
names |
Required | Variable names of the columns. Columns not appearing in the model are ignored |
X |
Either this or cov |
Data matrix (rows are observations; a row is dropped if any model variable in it is null) |
cov, n, mean |
Either this or X |
Covariance matrix and sample size (plus means if a mean structure is used) |
rescale_cov |
true |
Treat cov as unbiased (divided by n−1) and multiply it by (n−1)/n for maximum likelihood (the lavaan default) |
type |
"sem" |
"sem", "cfa" or "growth" (growth includes a mean structure, fixes the observed intercepts to 0 and frees the latent means) |
meanstructure |
false |
Estimate a mean structure (intercepts) |
return_scores |
false |
Return factor scores (regression method; only with X) |
The parameters added by default are the same as in lavaan’s sem(), cfa() and growth() (with fixed.x = FALSE): the loading of the first indicator of each factor is fixed to 1, and the variances of all variables are free, as are the covariances among exogenous latent variables, among exogenous observed variables and among the final dependent variables.
Latent growth curves POST /v1/sem/growth
| Parameter | Default | Description |
|---|---|---|
names, X |
Required | Column names and data matrix (cov, mean and n may be used instead, but then factor scores are not returned) |
time_vars |
All columns except covariates |
One column per time point (in time order) |
times |
0, 1, 2, … |
Time values (strictly increasing). The intercept i is the value at time 0 |
shape |
"linear" |
"linear", "quadratic" (4 or more time points) or "latent_basis" (the coefficients of the first two time points are fixed to times and the rest are estimated) |
covariates |
None | Time-invariant covariates. All growth factors are regressed on them |
equal_residuals |
false |
Constrain the residual variances to be equal across time points |
compare_shapes |
true |
Also fit intercept-only, linear, quadratic and latent basis models, and run χ² difference tests on the nested pairs |
return_scores |
true |
Individual factor scores (regression method) |
The syntax field of the response is the generated lavaan syntax; passing it as is to /v1/sem/fit with type: "growth" gives the same results.
Imitation test POST /v1/tests/imitation
When a behaviour (0/1) appears to spread across covariate space, this tests whether that reflects fluctuation of the units’ characteristics x themselves or imitation among units with similar characteristics. It implements the split-sample instrumental-variables (IV) method of Section 8 of the paper “Regression Functions as Fields on Covariate Space”.
For the product \(q_t = m_t f_t\) of the regression function \(m_t(x) = \Pr(Y_t = 1 \mid X_t = x)\) and the covariate density \(f_t\), the API regresses
\[ \partial_t q = \mathcal L_X^{*} q + \tfrac12\bigl\{\Sigma_I\, q'' - m\, \Sigma_I f''\bigr\} + f\,r\,m(1-m)(m-a) \]
on Gaussian-kernel smoothed \(q\) and \(f\). Here \(\mathcal L_X^{*}\) is the Fokker–Planck operator of the covariate OU process \(dX = -\theta X\,dt + \sqrt{\Sigma}\,dW\), and \(\theta\) and \(\Sigma\) are estimated from covariate increments alone. On the regression field, imitation acts through the same operator as covariate fluctuation, so the two cannot be told apart from the regression field alone; they are separated only by a panel that follows the covariates of the same units. The null hypothesis is \(H_0: \Sigma_I = 0\) (no imitation), against \(\Sigma_I > 0\).
Procedure: the units are split at random into halves; the regressors of one half are instrumented by those of the other, the roles are swapped and the two estimates averaged (this removes the attenuation caused by noisy second derivatives). The standard error comes from a bootstrap that resamples units with replacement within each half.
Required data
| Parameter | Default | Description |
|---|---|---|
x |
(required) | Covariates, a 2-D array of time × unit (x[k][i] is unit i at time k). At least 100 units and 4 times; N × T ≤ 4,000,000 |
y |
(required) | Outcomes, same shape as x, each 0 or 1 |
t or dt |
(one required) | Observation times (equally spaced), or the spacing. With dt you may also give t0 (default 0) |
grid / grid_n |
23 points | Points of x where the field is evaluated. By default, grid_n equally spaced points between the 5% and 95% quantiles of x pooled over all times |
h |
0.16 × the standard deviation of x | Gaussian kernel bandwidth (in units of x); 0.03–2 standard deviations |
tmin |
the second observation time | Earlier times are not used in the regression (to drop the initial transient) |
nboot |
49 | Number of bootstrap draws (10–199) |
seed |
0 | Random seed for the split and the bootstrap; the same value reproduces the same result |
The request body may be up to 96 MB (8 MB for other endpoints). Rounding x to about 6 decimals lets 100,000 units × 31 times fit. Send it with Content-Type: application/json (with curl’s default form encoding for -d, bodies over 8 KB are rejected with 413). The free demo POST /v1/demo/tests/imitation accepts N × T ≤ 50,000; at that size the standard error is large and the test has almost no power (it is for trying out the call).
Assumptions
- The same units are observed at every equally spaced time (missing values are not supported).
- The covariate is one-dimensional and follows an OU process around its mean (with \(\theta = 0\), it is frozen or a Brownian motion). Internally, x is standardized by its mean and standard deviation pooled over all times; \(\Sigma\) and \(\Sigma_I\) are converted back to the original units.
- Outcomes change by a bistable reaction \(r\,m(1-m)(m-a)\) and imitation of nearby units. Imitation is approximated by diffusion, so \(\Sigma_I\) is underestimated when the imitation window is wide compared with the scale of the field (by about 17% in the paper’s experiment without covariate fluctuation).
- It is not identified on a travelling (logistic) front, where the diffusion and reaction regressors are nearly collinear. Use it on fields with initial adopters seeded at several places in covariate space, or on transients.
- Its performance has been checked only on synthetic data from the paper’s own agent-based model (N = 10⁵, 31 times). The bootstrap standard error was conservative without imitation (0.010 versus a Monte Carlo standard deviation of 0.007), but too small when the covariates did not move.
Output
| Key | Description |
|---|---|
Sigma_I, se, z, pvalue |
Estimated diffusion due to imitation, bootstrap standard error, z = Σ_I / se, one-sided p-value (normal approximation) |
Sigma, theta, Sigma_total |
Diffusion and mean-reversion rate of the covariate OU process, and Σ + Σ_I |
r, a |
Rate and threshold of the bistable reaction |
grid, h, tmin, rows_per_half |
The grid range, bandwidth and start time actually used, and the number of regression rows |
standardization |
Mean and standard deviation used for standardization |
warnings |
Notes on discarded bootstrap draws or on a outside 0–1 |
It is accepted as a job; when finished, the result is in result of GET /v1/jobs/{id}.
job = requests.post(f"{API}/v1/tests/imitation", headers=H,
json={"x": X.round(6).tolist(), "y": Y.tolist(), "dt": 0.1}).json()
# ... wait until status is done, as for Gray-Scott
res = requests.get(f"{API}/v1/jobs/{job['id']}", headers=H).json()["result"]
print(res["Sigma_I"], res["se"], res["pvalue"])Verification: given the same split and the same bootstrap indices as the paper’s ancillary code estimate.py, the estimates and bootstrap values agree to a relative error of \(10^{-9}\). Reproducing the paper’s scenarios (no imitation / Σ_I = 0.06) five times each gave means of 0.005 / 0.057 and rejection rates of 0.00 / 1.00 (paper: 0.001 / 0.056, 0.00 / 1.00).
Gray-Scott POST /v1/sim/gray-scott
\[ \partial_t u = D_u \nabla^2 u - u v^2 + F(1-u), \qquad \partial_t v = D_v \nabla^2 v + u v^2 - (F+k) v \]
| Parameter | Default | Range |
|---|---|---|
n |
256 | 16–512 (side length of the grid; periodic boundary) |
steps |
10000 | 1–100000 (subject to \(n^2 \times\) steps \(\le 512^2 \times 20000\)) |
F, k |
0.035, 0.065 | 0–0.2 |
Du, Dv |
0.16, 0.08 | 0–1 |
dt |
1.0 | \(dt \cdot \max(D_u, D_v) \le 0.25\) (stability condition of the explicit Euler method) |
seed |
Random | The same value reproduces the same result |
init |
"center" |
"center" (seed at the center) / "random" (seeds at random positions) |
Errors
Errors are returned in the following form (shown here with ?lang=en).
{"error": {"code": "invalid_argument", "message": "series length must be 10–100000"}}| HTTP | code | Meaning |
|---|---|---|
| 400 | invalid_argument / invalid_json |
Invalid input (not charged) |
| 401 | unauthorized |
Missing or invalid key |
| 402 | insufficient_credit |
Insufficient balance |
| 413 | payload_too_large |
Request body too large (96 MB for the imitation test, 8 MB otherwise) |
| 429 | rate_limited / too_many_jobs |
Limit of 60 calls per minute or 3 concurrent jobs reached |
Free demo
You can try these without a key (up to 500 points per series).